#master_checkbox - filtered rows still selected, how to unch

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 dhtmlx.com/docs/products/kb/inde … getRowsNum, it proved unhelpful as the patch didn’t solve the problem.

  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]+""+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]+""+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;


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.

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.