DataTable不显示JSON数据

时间:2018-03-20 06:13:14

标签: c# asp.net ajax datatable

            var table = $('#datatables').DataTable({
                ajax: {
                    url: '@Url.Action("GetGrid","Vibrant", new { Area = "Marketing" })',
                    type: 'GET',
                    data: {
                        //filters here
                        columns: null,
                        filter: function () { return _filter; },
                    },
                    success: function (data) {
                        console.log("success", data);
                    },
                    error: function (data) {
                        console.log("error", data);
                    }
                },
                processing: true,
                serverSide: true,
                responsive: true,
                pagingType: 'full_numbers',
                language: {
                    search: "_INPUT_",
                    searchPlaceholder: "Search records",
                },
                columns: [
                    { "data": "ID"},
                    { "data": "PreviewID"},
                    { "data": "EPCElement"},
                    { "data": "Vibrant"}
                ],

方法成功返回数据,但DataTable不会显示它。

            initialList = (from pjob in _db.PropertyJobs
                       select new SendVibrantOrderGridVM
                       {
                           ID = pjob.ID,
                           PreviewID = pjob.PreviewID,
                           EPCElement = pjob.EPCElement ,
                           Vibrant = pjob.Vibrant 
                       }).ToList();

我正在尝试用我在调用方法中获得的JSON数据填充我的DataTable。

这是GetGrid方法返回的示例数据:

{"data":[{"ID":529,"PreviewID":999992349,"EPCElement":false,"Vibrant":false}],"draw":1,"page":1,"pages":113,"length":10,"recordsTotal":1126,"recordsFiltered":1126}

0 个答案:

没有答案