refresh footer with distinct count

I find how to add a footer with some calculations of the data in my grid like for example

mygrid.attachFooter("Row count:{#stat_count}")

Now I want a specific calculation. I want to get the distinct values of a certain column. For example a book store. With the code above I can get the numbers of books I have in my store, but I also want the number of distinct authors of my store. I use this code for it:

mygrid._in_header_stat_rowcount=function(tag,index,data){ var calc=function(){ return mygrid.collectValues(23).length; } this._stat_in_header(tag,calc,index,data); } mygrid.attachHeader("author count:{#stat_rowcount}");

The problem is that when I use the #text_filter, the custom author count doesn’t change like the #stat_count. How can I do that?

Please, try to use the following function:

myGrid._in_header_stat_rowcount=function(tag,index,data){ var calc=function(){ var total=0; var found = {}; this.forEachRowA(function(id){ var val=this.cellById(id,23).getValue(); if (!found[val]){ found[val] = true; total++; } }) return total; } this._stat_in_header(tag,calc,index,data); }