Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Steve O. on Aug 13, 2008 03:03
open dhtmlx forum
dhtmlxGrid: custom filter in headers

Hello to all,

How can I put a custom filter in the sub-headers of the grid ?
...
<script>
    function linkfilter(val) {   // custom filter function
        val = (val||"").split("^")[0].replace(/<[^>]*>/g,"");
        if (val.indexOf(MASK)!=-1) return true;
        return false; }
...
        mygrid.setHeader("Title,Link");  // headers
        mygrid.attachHeader("#text_filter,#linkfilter");  // subheaders
...
        mygrid.init();
        mygrid.loadXML("xml_results.asp");
...
</script>
...


Answer posted by Support on Aug 13, 2008 03:21
Technically you can place any custom html inside header, it can be a filtering form as well. 
If you want to create custom "shortcut" - please check related article.
http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Custom_content_in_header.htm#grid_ccingrid

There is a one more, tricky solution, which can be used

...
mygrid.attachHeader("#text_filter,#text_filter");
mygrid.init();

mygrid.hdr.rows[1].cells[1].getElementsByTagName("INPUT")[0]._filter=function(){
      var mask=this.value;
      return function(val){
          //filtering logic here
      }
});

by such code, filtering logic of existing text filter can be changed to custom one.