Add/Delete columns with filters after grid rendered


#1

Hi,

I have initiated grid with json on client side. and added a filter header like this for every column in grid.
viewModel.auditGrid.attachHeader("#numeric_filter,…");

and i have a requirement to add/delete new columns to grid after init and those columns should have filters.
I searched in docs and could not find any api that lets to add column with filter .

I have tried to reset filter header that I specified at init is also not resetting properly when i call
self.auditGrid.detachHeader(1);

and add all filters with

self.auditGrid.attachHeader("#..."); //updated filter header with all new+old column filters

when i filter in newly added column grid breaks with this error

    Uncaught TypeError: Cannot read property '_cellType' of undefined
        at window.(anonymous function).cells5 (http://localhost/SIO/Scripts/dhtmlx.js:9:858579)
        at window.(anonymous function).cells3 (http://localhost/SIO/Scripts/dhtmlx.js:9:858425)
        at window.(anonymous function).(anonymous function) [as cells3] (http://localhost/SIO/Scripts/dhtmlx.js:9:1054922)
        at window.(anonymous function)._get_cell_value (http://localhost/SIO/Scripts/dhtmlx.js:9:851830)
        at window.(anonymous function).temp (http://localhost/SIO/Scripts/dhtmlx.js:9:1136950)
        at g (dhtmlx.js:9)
        at a (dhtmlx.js:9)
        at window.(anonymous function).temp (http://localhost/SIO/Scripts/dhtmlx.js:9:1136857)
        at g (dhtmlx.js:9)
        at a (dhtmlx.js:9)

I have Dhtmlx 5.1.0 Professional Edition


#2

Unfortunately the dynamic filters detaching/attaching is not supported in the dhtmlx Grid.
While you have detached the header the filters are no destroyed. You need to clear these filter objects calling:

myGrid.filters=[];

after the header detaching.