I have a datasource with a filter applied to it. When I enable filterable search for the listview, it wipes out the original filter on the datasource. How can I get it to search WITHIN the filtered data subset?
Here is the issue in action: http://jsfiddle.net/KS7dB/. It is filtered by {b: "2B"}. Start entering "ds" in the search and it wipes out the filter and starts searching everything instead of only the filtered subset. Any idea on how to fix this behavior?
var ds1 = new kendo.data.DataSource({
data: [{
stagename: "ds1 A",
b: "1b"
}, {
stagename: "ds1 B",
b: "2b"
}, {
stagename: "ds1 C",
b: "2b"
}, {
stagename: "ds1 D",
b: "2c"
}, {
stagename: "ds1 E",
b: "2c"
}],
filter: {
field: 'b',
operator: 'eq',
value: '2b'
}
});
$("#stages_listview").kendoMobileListView({
dataSource: ds1,
template: $("#stages_listview_template1").html(),
filterable: {
field: 'stagename',
operator: 'contains',
ignoreCase: true
}
});
I did spent some time digging into this and the problem is that as soon as you create filter on your listview, in practice that is a filter on the underlining data source, they are not two separate cumulative filters . Therefore behaviour you observed seems to be correct.
Work around options:
override the filter function on the data source so it takes argument passed to it via listview and always append the default data source filter. Something alongside these lines. I have to admit I didn't manage to craft final and functional solution.
lw.dataSource.filter = function() {
arguments[arguments.length]= { field: "b", operator: "eq", value: "2b" };
arguments.length += 1;
var result = lw.dataSource.originalfilter.apply(this, arguments);
return result;
}
filter server side