2014-02-24 3 views
0

JavaScript에서 dataTable의 객체 값을 검색하고 싶습니다. 내 oject 반환JavaScript 및 DataTable

여기

[OperationContract] 
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json)] 
    ResponseStatistic_1 Statistic_1(); 

여기
public class ResponseStatistic_1 : IBaseClientEntity 
{ 
    public ResponseStatistic_1() 
    { 

    } 

    public ResponseStatistic_1(Statistic_1 [] items) : this() 
    { 
     this.Items = items; 
    } 

    public Statistic_1[] Items 
    { 
     get; 
     set; 
    } 
} 

내 Statistic_1.cs 여기

public class Statistic_1 
{ 
    private string _geografisch_zone; 
    private decimal[] _sum; 
    private int _yearStart; 
    private int _yearEnd; 

    public Statistic_1() 
    { 
    ... 
    } 

    public string Geografisch_zone 
    {... 
    } 

    public decimal[] Sum 
    { 
    ... 
    } 

    public int YearStart 
    { 
    ... 
    } 

    public int YearEnd 
    { 
    ... 
    } 
} 

내 내 ResponseStatistic_1.cs 내 웹 서비스에 ResponseStatistic_1입니다 자바 스크립트의 코드 :

function getStatistic1() { 

var response; 
var allstat1 = []; 

$.ajax({ 
    type: 'GET', 
    url: 'http://localhost:52768/Service1/Statistic_1', 
    contentType: 'application/json; charset=utf-8', 
    dataType: 'json', 
    success: function (msg) { 
    response = msg.d; 
    for (var i = 0; i < response.length; i++) { 

     allstat1[i] =**???** 

    } 

     fillData(allstat1);**???** 

    }, 
    error: function (e) { 
     alert("error loading statistic 1"); 
    } 
}) 
} 

function fillData(data) { 

$('#table_campaigns').dataTable({ 
    **???** 
}); 
} 

우리는 이렇게해야합니까?

답변

0

은 용액이었다

$('#table_statistic_1').dataTable({ 

    'aaData': data, 
    'aoColumns': [ 
     { "sTitle": ""}, 
     { "sTitle": allyearstat3[0][0] }, 
     { "sTitle": allyearstat1[0][1] } 
    ], 

}); 
:
allyearstat1[0] = [response.Items[0].PropertyName, response.Items[0].PropertyName]; 

Ans By의

가 dataTables을 채울