Grid PARSE json (js) with custom excell type


#1

i have a custom excell type that works great when i use addRow() method of dhtmlx grid.

However i must implement pagination and found out that addRow called inside a loop doesnt work fast enough so i need to implement the parse method.

i tried: mygrid.parse(data, '‘json’) but unfortunatelly it throws error when i have an object value (non string value) inside data array.

Here is an example to make it more clear:

const gridData = {
    rows:[
        { id:1, data: ["A Time to Kill", "John Grisham", "100"]},
        { id:2, data: ["Blood and Smoke", "Stephen King", "1000"]},
        { id:3, data: ["The Rainmaker", "John Grisham", "-200"]}
    ]
};

grid.parse(gridData, 'json')

The above code works and the data renders on the page BUT in case i have custom excell column and my data is like this:

const gridData = {
        rows:[
            { id:1, data: ["A Time to Kill", customObjValue, "100"]},
            { id:2, data: ["Blood and Smoke", customObjectValue, "1000"]},
            { id:3, data: ["The Rainmaker", "customObjectValue", "-200"]}
        ]
    };

where customObjectValue is soemthing like:

const customObjectValue = {
     check_state: true,
     label: 'some text goes here',
     onclick: () => {
         //........
     } 
}

when i call grid.parse(gridData, 'json') it trows an error.

Any help is greatly appreciated.

P.S. I am using version 5.


#2

please, make sure that you are using the PRO version of the dhtmlxGrid, as the extrended json is supported only in this pro version.