arrays - DataTables - Load data from pre-defined JSON -


i have problem pointing datatable right spot in json. receive nested array:

{ "status": "ok", "count": "7", "msg ": "operation successful", "data": [{     "contacthasservicearea": true,     "issuecategories": [{             "id": "8",             "description": "finance"         },         {             "id": "9",             "description": "housing"         },         {             "id": "10",             "description": "international"         }     ],     "cases": [{         "id": 31645,         "client_name": "matthew",         "issue": "assessment completion",         "referral": null,         "opened_date": "10\/07\/2017",         "case_status": "open"     }, {         "id": 31668,         "client_name": "fanky ",         "issue": "complex",         "referral": null,         "opened_date": "01\/07\/2017",         "case_status": "open"     }] }] 

}

how point "cases" object? i'm sure simply, i'm confused many options in datatables config.

i tried variations of data, datasrc data.cases or cases, etc. thanks

 $('#cases_table').datatable( {         "ajax": "ajax/getcases",         "datasrc"   : "data.cases",         "data"      : "cases",         "columns": [             { "data": "client_name" },             { "data": "issue" },             { "data": "referral" },             { "data": "opened_date" },             { "data": "case_status" }             ]     } ); 

you can configure this:

$('#cases_table').datatable( {   "ajax": {      "url": "ajax/getcases",      "datasrc"   : "data.cases"    },    "columns": [        { "data": "client_name" },        { "data": "issue" },        { "data": "referral" },        { "data": "opened_date" },        { "data": "case_status" }     ]   } ); 

datasrc points returns json. remove data option.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -