Event in master_CheckBox

Hi, how do I attach an event in master_CheckBox on header?

thanks

It can be done only with code modification. In the dhtmlxgrid_filter.js file:

dhtmlXGridObject.prototype._in_header_master_checkbox=function(t,i,c){ t.innerHTML=c[0]+"<input type='checkbox' />"+c[1]; var self=this; t.getElementsByTagName("input")[0].onclick=function(e){ //any custom code here ... }

tanks!!!

I have set the #master_checkbox in mygrid.attachHeader to check/uncheck all in column. This works to clear all checkboxes in column, but the grid does not update the table with these checked or unchecked changes. What am I missing? Thanks! Load via XML/PHP see code below;

mygrid.attachHeader("#text_filter,#select_filter,#text_filter,#text_filter,#master_checkbox,#master_checkbox,#master_checkbox,#master_checkbox, ,#master_checkbox");

mygrid.loadXML(“php/get_recog.php”);

The dataprocessor detects the row changed only by edit operations. If a row was changed by a direct API calling it will not be updated which happens when master_checkbox works. You can manually call the dataprocessor to inform about the update operation:

dhtmlXGridObject.prototype._in_header_master_checkbox=function(t,i,c){ t.innerHTML=c[0]+"<input type='checkbox' />"+c[1]; var self=this; t.getElementsByTagName("input")[0].onclick=function(e){ self._build_m_order(); var j=self._m_order?self._m_order[i]:i; var val=this.checked?1:0; self.forEachRowA(function(id){ var c=this.cells(id,j); if (c.isCheckbox()) c.setValue(val); dp.setUpdated(id,true); }); (e||event).cancelBubble=true; } }

Thank you Olga for the quick reply.
I have inserted the script in the dhtmlxgrid_filter.js file, but with no affect on updating the backend MySQL table.

Can you instruct me as to the full implementation of this?

Thank you for all of your help!

Sorry for inconveniences. There is bug in my code. Here should be:

dhtmlXGridObject.prototype._in_header_master_checkbox=function(t,i,c){ t.innerHTML=c[0]+"<input type='checkbox' />"+c[1]; var self=this; t.getElementsByTagName("input")[0].onclick=function(e){ self._build_m_order(); var j=self._m_order?self._m_order[i]:i; var val=this.checked?1:0; self.forEachRowA(function(id){ var c=this.cells(id,j); if (c.isCheckbox()) { dp.setUpdated(id,true); c.setValue(val); } }); (e||event).cancelBubble=true; } }
Where dp - instance of dhtmlxDataProcessor object.

Hello Olga,

I have tried inserting the code from your last entry (sans bugs) and have not been able to
get it to fire off and record a change for the master checkbox. I have turned on debugging, and
the master_checkbox event does not register in debug window. Any help would be appreciated.
Also, should this be placed in dhtmlxgrid_filter.js or dhtmlxdataprocessor.js ? Thank you!

Please provide code snipped of DataProcessor initialization.

Thank you Olga, below is the init code:

var dp = new dataProcessor(“php/update_recog.php”);
dp.init(mygrid);

Update: I now have this firing off and recording in the debug window and the backend MySQL table, but I have a different problem now, clicking the “Master Checkbox” has the opposite effect i.e. if I want all cells in column checked, I must uncheck the “Master Checkbox” which will de-select all cells in column (correct). When table is refreshed, the cells are all checked and vice-versa.

Change the order of commands in above code snippet

Instead of

dp.setUpdated(id,true); c.setValue(val);

You need to use

c.setValue(val); dp.setUpdated(id,true);

Works perfectly! Thank you.