(DHTMLX Grid) Use Checkbox to turn on/off Split Grid?

792 Views Asked by At

I'm using DHTMLX Grid, and would like to create the functionality of turning on and off the splitAt() function. It works fine by itself, I understand that it will not work just by calling the function on change, the grid needs to be re-enabled each time the instance is called.

My JavaScript:

function doSplitGridCheck()
{
    if(document.getElementById('z3').checked)
        mygrid.destructor();
        mygrid.splitAt(1);
    else
        mygrid.destructor();
}

or something like this:

function doSplitGridCheck()
{
    if(document.getElementById('z3').checked)
        mygrid.clearAll();
        mygrid.loadXML("../db/test.xml");
        mygrid.splitAt(1);
    else
        mygrid.clearAll();
        mygrid.loadXML("../db/test.xml");
}

My HTML:

<div><input id='z3' type="checkbox" checked='true' onclick='doSplitGridCheck()' />Split View</div>

I'm not entirely sure if this is possible, but I'm not very good with JS, so I've come here for suggestions! I know that the order of events needs to be to (1) stop the grid, (2) reload the grid, (3) and then reapply the splitAt() function if checked.

All help is appreciated. I'm not sure what you need from me so ask away!

Note: mygrid.destructor() & mygrid.splitAt() are functions of DHTMLX Grid.

1

There are 1 best solutions below

2
On

Unfortunately, the dynamic switching of the split mode on/off is not supported. The only way is to destruct your grid object and create a new one without the split. You need to use the destructor() method.

PLease, note that calling the destructor() you completely remove your grid object and after that you need to create a new one:

  myGrid.destructor();
   myGrid = new dhtmlXGridObject('gridbox');
   myGrid.setImagePath("../../codebase/imgs/");