Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Mike on Jun 23, 2008 07:08
open dhtmlx forum
deleteRow causes error when results are filtered

I have a grid with a couple of hundred rows in it. When I use the deleteRow function everything works fine as long as the grid isn't filtered. However when I apply a filter then use the deleteRow function I get a JS error: '0' is null or not an object.

After I get the error the row is removed from my grid, however once I remove the filtering the row appears again in my result set.

my code for running the deleteRow function is: mygrid.deleteRow(Admin_ID,mygrid.getRowIndex(Admin_ID));

Where "Admin_ID" is the ID I've used for the row.

Please help.
Answer posted by Support on Jun 23, 2008 08:21
The rows can't be added|deleted while grid in filtered state. This is limitation of current version.

As possible workaround you can use next approach
    - unfilter grid
    - delete necessary rows
    - filter grid back by the same rules

            mygrid.filterBy(0); //unfilter
            mygrid.deleteRow(id)
            //next line clears all inner buffers
            mygrid._srowsCol=mygrid._f_rowsBuffer=mygrid._srowsBuf=null;
            mygrid.filterByAll(); // restore filters

Answer posted by Mike on Jun 23, 2008 08:47
Thanks, this works as expected now.