binding and filters

Dear Friends,

I bind lists as master and slave, but when I apply filter in slave, the filter dose not strict the binding rule.

pls see=> http://disq.us/p/1gun4hc

How can I filter and set it strict with binding rule?

Thank you
(sorry for my English)

Hello,

In essence, the slave collection is filtered according to the binding rule. So, when it is filtered by header filters, the binding filter is ignored.

You can change the .filterByAll() method of the slave Datatable to preserve your binding rule.

The filterByAll() method is called automatically, when the Datatable filters itself according to header filters. So, you need to apply the basic logic in it and filter the data again according to the binding rule: this.filter(rule, text, preserve).

var baseFilter = gridb.filterByAll;

gridb.filterByAll=function(){
  baseFilter.call(this);
  //repeat your binding rule
  this.filter(function(obj){
    //getCursor returns id of selected record in master
    return obj.index == grida.getCursor();
  }, null, true); //here the 3rd parameter preserves the existing filtering
};

gridb.bind(grida, function(slave, master){ 
  return master.id == slave.index;
});	

Check the following snippet, please: http://webix.com/snippet/fe13d3f4

Great!!
Thanks

Good example. But I’d like to go deeper, and preserve filtering in slave table when selection in master table is changed. Is it possible?

You can filter the slave datatable according to existing filters after bound data is parsed into it:

on:{
   onBindApply:function(){
	this.filterByAll();
   }
}

https://snippet.webix.com/ivjf3r0n