Hello,
I'm using a multiselect filter for the one of my columns. Also I want to maintain the active filters so you can further narrow down the result.
For now i'm trying to do this as below but the OldFilters variable is empty.
function areaOfStudyFilter(element)
{
//mvvm binding should be removed, other way the dataSource will try to update the UI when the dataSource filter has changed
element.removeAttr("data-bind");
var dataSource = $("#Grid").data("kendoGrid").dataSource
element.kendoMultiSelect({
optionLabel: "-Selecteer waarde-",
dataSource:
{
transport: {
read: "@Url.Action("Filter_AreaOfStudyDescriptions")"
}
},
change: function (e) {
var oldFilters = dataSource.filter();
var filter = {logic:"and", filters:[]}
var newFilter = { logic: "or", filters: [] };
var values = this.value();
if (values.length == 0)
{
dataSource.filter({ field: "AreaOfStudy", operator: "startswith", value: "" })
oldFilters = dataSource.filter();
}
$.each(values, function (i, v) {
newFilter.filters.push({ field: "AreaOfStudy", operator: "eq", value: v });
dataSource.filter({ field: "AreaOfStudy", operator: "startswith", value: "" })
oldFilters = dataSource.filter();
});
filter.filters.push(newFilter);
filter.filters.push(oldFilters);
dataSource.filter(filter);
}
});
}
Kind Regards,
Tim
I'm using a multiselect filter for the one of my columns. Also I want to maintain the active filters so you can further narrow down the result.
For now i'm trying to do this as below but the OldFilters variable is empty.
function areaOfStudyFilter(element)
{
//mvvm binding should be removed, other way the dataSource will try to update the UI when the dataSource filter has changed
element.removeAttr("data-bind");
var dataSource = $("#Grid").data("kendoGrid").dataSource
element.kendoMultiSelect({
optionLabel: "-Selecteer waarde-",
dataSource:
{
transport: {
read: "@Url.Action("Filter_AreaOfStudyDescriptions")"
}
},
change: function (e) {
var oldFilters = dataSource.filter();
var filter = {logic:"and", filters:[]}
var newFilter = { logic: "or", filters: [] };
var values = this.value();
if (values.length == 0)
{
dataSource.filter({ field: "AreaOfStudy", operator: "startswith", value: "" })
oldFilters = dataSource.filter();
}
$.each(values, function (i, v) {
newFilter.filters.push({ field: "AreaOfStudy", operator: "eq", value: v });
dataSource.filter({ field: "AreaOfStudy", operator: "startswith", value: "" })
oldFilters = dataSource.filter();
});
filter.filters.push(newFilter);
filter.filters.push(oldFilters);
dataSource.filter(filter);
}
});
}
Kind Regards,
Tim