Categories | Question details Back To List | ||
#master_checkbox - filtered rows still selected, how to uncheck Hello. 1. Using the master checkbox to select all rows selects rows that are filtered. Is there any way to ignore the unseen rows? I tried, but the grid doesn't use any known attributes for hidding the rows (e.g. "visible=false"). Is there any ways to iterate on rows and test to see if each row is hidden or not? 2. How can I access the master checkbox? I tried using mygrid.cells(0,0), same by header rowID (not sure if there is any ID for it). I need to uncheck it after performing some action on checked rows. Thanks in advance, Dror PS. Read the Q&A at http://dhtmlx.com/docs/products/kb/index.shtml?cat=search&page=1&q=4699&ssr=yes&s=master%20checkbox%20getRowsNum, it proved unhelpful as the patch didn't solve the problem. Answer posted by dhxSupport on Sep 23, 2009 08:31 1. It can be done only with code modification. In the file dhtmlxgrid_filter.js you can change rows: dhtmlXGridObject.prototype._in_header_master_checkbox=function(t,i,c){ t.innerHTML=c[0]+"<input type='checkbox' />"+c[1]; var self=this; t.firstChild.onclick=function(e){ self._build_m_order(); var j=self._m_order?self._m_order[i]:i; var val=this.checked?1:0; self.forEachRow(function(id){ var c=this.cells(id,j); if (c.isCheckbox()) c.setValue(val); }); (e||event).cancelBubble=true; } } With following: dhtmlXGridObject.prototype._in_header_master_checkbox=function(t,i,c){ t.innerHTML=c[0]+"<input type='checkbox' />"+c[1]; var self=this; t.firstChild.onclick=function(e){ self._build_m_order(); var j=self._m_order?self._m_order[i]:i; var val=this.checked?1:0; for (var ind=0; ind<self.getRowsNum();ind++){ var c=self.cells(self.getRowId(ind),j); if (c.isCheckbox()) c.setValue(val); }; (e||event).cancelBubble=true; } } 2. You can access to the master checkbox only with DOM: var m=mygrid.hdr.rows[HEADER_ROW_INDEX].cells[COLUMN_INDEX].firstChild.firstChild; Answer posted by Dror on Sep 27, 2009 03:17 Thanks for the quick reply. While issue #1 works perfectly with the code change you suggested, I still could not resolve issue #2. var m=mygrid.hdr.rows[HEADER_ROW_INDEX].cells[COLUMN_INDEX].firstChild.firstChild I tried this with all comnibations of (HEADER_ROW_INDEX = 0/1, COLUMN_INDEX = 0/1, using .firstChild or .firstChild.firstChild) but nothing worked. 1. Is HEADER_ROW_INDEX a parameter or simply the numeric row index of the header row (which is probably 0, but possibly 1 as this header is joined using #rspan to avoid using filtering on it)? 2. Why is the "firstChild" called twice - meaning, is the master checkbox really wrapped in some other object which is wrapped in the header cell? If so, what object is it wrapped in? Thanks again, Dror. Answer posted on Sep 28, 2009 07:08 You can get reference to the master checkbox with following script: var master=this.hdr.rows[2].cells[ind].getElementsByTagName("INPUT")[0]; This code locates the HTML object of master checkbox, it expects that checkbox sits in second row of header. |