Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Michael on Jan 14, 2010 16:46
open dhtmlx forum
Linked Filters in Dhtmlx Grid

I have a dhtmlxGrid with several filtes in the head - text, and select filters. It uses smart paging, on the client side. Is there a way to filter the choices displayed in one filter based on the selection of another.

For example: A grid lists all actors in a list of films. one column is studio that produced the film, the second column lists the name of the movie and the grid displays the studio, film name and actor. Can i set the filters so that if I select "Sony" from teh studio list the film select filter will display only the titles of films producted by Sony (and not films by Fox or Universal etc.) and the grid lists all actors for films produced by Sony?

Thanks,
Michael
Answer posted by Stanislav (support) on Jan 15, 2010 02:45
Can be achieved only by code modification

dhtmlxgrid_filter.js 

dhtmlXGridObject.prototype.collectValues=function(column){
...
var col=this._f_rowsBuffer||this.rowsBuffer;

need to be replaced with 

var col=this.rowsBuffer;

after that you can add next code to the grid's init to force necessary behavior


grid.attachEvent("onFilterEnd",function(){
     grid.refreshFilters();
})



Answer posted by Michael on Jan 15, 2010 07:47
Using this modified functionality, how would I specify that #select_filter_A is driven off the selection of #select_filter_B?

Thanks,
Michael
Answer posted by Alex (support) on Jan 15, 2010 08:26

collectValues method gets column index as a paramater.

So you can check the index and call only var col=this._f_rowsBuffer||this.rowsBuffer; for the column with #select_filter_B:

dhtmlXGridObject.prototype.collectValues=function(column){
...
if(column == SOME_INDEX)

var col=this._f_rowsBuffer||this.rowsBuffer;
else
var col=this.rowsBuffer;