2

On calling grid.parse(jsonstr, 'json') in js code the report is not getting displayed nor it throws any error though all the headers are getting displayed. Code below:

function getReportData(data) {
    var gr = new dhtmlXGridObject('gridbox');
    gr.selMultiRows = true;
    gr.setHeader(data['tVals']['header']);
    gr.setInitWidths(data['tVals']['init_widths']);
    gr.setColAlign(data['tVals']['col_align']);
    gr.setColTypes(data['tVals']['col_types']);
    gr.setColSorting("str,str");
    gr.init();
    gr.parse(data['gData'], 'json');
}

PS: data has all the relevant information required by the code. Also my html has following js imports:

dhtmlxcommon.js
dhtmlxgrid.js
dhtmlxgridcell.js
dhtmlxtreegrid.js
dhtmlxgrid_json.js
dhtmlxgrid_hextra.js
jquery version 1.6.1
Anton Sizikov
  • 9,105
  • 1
  • 28
  • 39

2 Answers2

0

The issue is seems to be in the format of your JSON. Can you provide a sample of your JSON string? You can find an example of valid JSON supported by dhtmlxGrid here: http://docs.dhtmlx.com/doku.php?id=dhtmlxgrid:syntax_templates#json_format_details

Paul
  • 1,656
  • 11
  • 16
0

It would really help if you posted your JSON format, however I think I know what your problem is:

There are two formats of JSON that you can use in DHTMLX ( more details on https://docs.dhtmlx.com/grid__data_formats.html#jsonformat)

So the solution to your issue should be very simple.

Change

gr.parse(data['gData'], 'json'); 

to

gr.parse(data['gData'], 'js');
usmanali
  • 2,028
  • 2
  • 27
  • 38
Giouri
  • 11
  • 6