Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Victoria Elinson on Jan 15, 2010 09:17
open dhtmlx forum
changing master checkbox behavior without modifying dhtmlxgrid_filter.js

Hi,

I would like to change master checkbox behavior. I have seen other posts that suggest modifications to dhtmlxgrid_filter.js I want to try an alternative way because I am using this file on many pages and only one requires a different behavior. I am trying to do this using jquery as follows:


$("div.hdrcell").find("input[type=checkbox]").unbind("click").click(
        function(){
alert("do nothing");
}
);

my alert("do nothing") does get triggered in ADDITION rather then INSTEAD of the old behavior. Any idea what I should try ?

thanks!!!!

Victoria
Answer posted by Stanislav (support) on Jan 15, 2010 09:26
Instead of changing existing one, you can create a custom one

Add the next code to the page or separate js file

dhtmlXGridObject.prototype._in_header_my_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.forEachRowA(function(id){
               var c=this.cells(id,j);
               if (c.isCheckbox()) c.setValue(val);
          });
          (e||event).cancelBubble=true;
     }
}

Now you can use #my_checkbox in grid's header
Of course, you can change above code in any necessary way. 
Answer posted by Victoria on Jan 15, 2010 09:46
This is great! Thank you so much!

Victoria