0

This is my response from action method:

{
    "draw": 1, "recordsTotal": 2, "recordsFiltered": 2, "data": [
        { "ISIN": "IMF284L016", "SubSchemeName": "Geliance jocused Marge Map  Plan-Growth Option", "TotalAmountInvested": 400.0000, "CurrentValue": 507.402400, "Client": "23", "ClientName": "Lweta Kain      " },

        { "ISIN": "IKF24K01o", "SubSchemeName": "", "TotalAmountInvested": 0.0000, "CurrentValue": 0.000000, "Client": "23", "ClientName": "Uweta Kain      " }

    ]
}

Below is my code

$('#orderBookTable').DataTable({

            "pageLength": 50,
            "bProcessing": true,
            "bServerSide": true,

            "ajax": {
                "url": "/Fund/Get",
                "type": "POST",
                "datatype": "Json",
                "data": function (d) {
                    d.clientCode = $("#sltClientName").val();
                },
                "columns": [
                    { "data": "SchemeName" },
                    { "data": "Client" },
                    { "data": "Invested" },
                    { "data": "CurrentValue" },
                    { "data": "CurrentValue" },
                ],
                "fnCreatedRow": function (d) {
                    debugger;
                }
            }
        });

please have look in to it. My server side code returning JsonResult using Json method

dev
  • 177
  • 1
  • 2
  • 14
  • Can you add code how you're binding the data and console error if any? – Rajeev Ranjan Apr 19 '18 at 12:47
  • no there is no console error. But it shows pop up error "Requested unknown parameter '0' for row 0, column 0." – dev Apr 19 '18 at 12:50
  • https://stackoverflow.com/q/16539578/3953479 this question has a similar error. – Rajeev Ranjan Apr 19 '18 at 12:54
  • let me chek that question – dev Apr 19 '18 at 12:55
  • I already went through that link , Now tell me how convert that response from Array of Objects to Array of Arrays – dev Apr 19 '18 at 12:57
  • can you share your code, where you're trying to do that – Rajeev Ranjan Apr 19 '18 at 13:01
  • I am using Json(Model) this method to return my object – dev Apr 19 '18 at 13:03
  • This is probably because you haven't set up your table to use objects - as you're returning objects in the JSON, you need to define the columns during the table initialisation. See the example here: https://datatables.net/examples/ajax/objects.html – colin0117 Apr 19 '18 at 13:10
  • I already had define the columns like that but still data is not binding to data table – dev Apr 19 '18 at 13:32
  • As Rajeev said, you need to share your table initialisation code - without it we're shooting blind... – colin0117 Apr 19 '18 at 13:33
  • Please look into client side code – dev Apr 19 '18 at 13:41
  • Yep, that's the problem, you see. When you define the columns, you're telling DataTables where to get the data for that column. However, you haven't got a SchemeName or an Invested field in your returned data. There's a subSchemeName, but not SchemeName. All fields in the columns initialisation, must be in the returned JSON data. – colin0117 Apr 19 '18 at 13:49
  • I have change the properties still error is there – dev Apr 20 '18 at 05:23

1 Answers1

0

As your response is complex JSON object, and as per documentation available here you should change your column initialization as below:

"columns": [
                { "data": "data.SchemeName" },
                { "data": "data.Client" },
                { "data": "data.Invested" },
                { "data": "data.CurrentValue" },
                { "data": "data.CurrentValue" },
            ],

Hope it helps !!

Rajeev Ranjan
  • 497
  • 4
  • 16
  • 1
    I have solved this issue By changing "bProcessing" to processing & "bServerSide" to ServerSide. I think that parameters not support in 1.10.18 version – dev Apr 20 '18 at 07:21