Columns data not populated from the Ajax data response.

Columns data not populated from the Ajax data response.

divyag10divyag10 Posts: 3Questions: 3Answers: 0

I'm getting ajax response as,
{"orderBy": "-studyDate", "count": 31, "slist": [{"patientid": "C45645", "originHospitalIp": null, "billingStatus": false, "refPhyDept": null, "loginSource": "LOCAL", "admissionID": " ", "VIP": false, "isInsurance": false, "streamingServerIp": null, "originHospitalWebPort": "None", "sex": "M", "bodyPartStr": "Head", "modality": "CT", "report_status_id": 0,"age": "041Y", "sex": "M", "reportIdForAddtionalAccNo": {}, "EntrprsCntr": 1, "seriesCount": 2, "streaminServerPort": "None", "bedName": " ", "showAdditionAccNo": false, "priorityValue": "Normal", "instanceuid": "22693"}, {"patientid": "C45645", "originHospitalIp": null, "billingStatus": false, "refPhyDept": null, "loginSource": "LOCAL", "admissionID": " ", "VIP": false, "isInsurance": false, "streamingServerIp": null, "originHospitalWebPort": "None", "sex": "M", "bodyPartStr": "Head", "report_status_id": 0, "age": "041Y", "sex": "M", "modality": "CT", "reportIdForAddtionalAccNo": {}, "EntrprsCntr": 1, "seriesCount": 2, "streaminServerPort": "None", "bedName": " ", "showAdditionAccNo": false, "priorityValue": "Normal", "instanceuid": "22729"}....]}

Script to load the columns is as below:

$(document).ready( function () {
var url = "..../...";

  $('#datagrid').dataTable( {
    "ajax": url,
        "columns": [
          { "slist": "patientid" },
          { "slist": "age" },
          { "slist": "sex" },
          { "slist": "bodyPartStr" },
      { "slist": "modality" }
      ],
    "lengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]]
  } );
} );

but the columns are not getting populated.

This question has an accepted answers - jump to answer

Answers

  • arielfmdparielfmdp Posts: 6Questions: 2Answers: 1
    edited June 2014 Answer ✓

    The options in columns are wrong, you have to set it like this:

    $('#datagrid').dataTable( {
    "ajax": url,

    "columns": [
    { "data": "slist.patientid" },
    { "data": "slist.age" },
    { "data": "slist.sex" },
    { "data": "slist.bodyPartStr" },
    { "data": "slist.modality" },
    ],

    "lengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]]
    } );
    } );

    The option "data" is required

This discussion has been closed.