This is a migrated thread and some comments may be shown as answers.

Complex custom filtering and "OR" not working?

1 Answer 193 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 04 Apr 2013, 03:44 PM
Hi Kendo team,

I have a page with a KendoUI grid. Above the grid is a textbox which allows custom searches using comma-separated values. In all other pages which use the grid without the custom search textbox, the built-in "AND" and "OR" filters work great.

When using this page, "OR" is always treated as "AND".

Here's an example of the form data being posted via ajax using "OR" for a column in the grid called "ToolDefinitionName".  I am also filtering on FacilityId = 39.  When this filter is run, it returns no data even though both ToolDefinitionNames are valid:

take:50
skip:0
page:1
pageSize:50
sort[0][field]:EntityCode
sort[0][dir]:asc
filter[logic]:and
filter[filters][0][field]:FacilityId
filter[filters][0][operator]:eq
filter[filters][0][value]:39
filter[filters][1][logic]:or
filter[filters][1][filters][0][field]:ToolDefinitionName
filter[filters][1][filters][0][operator]:eq
filter[filters][1][filters][0][value]:PIZio
filter[filters][1][filters][1][field]:ToolDefinitionName
filter[filters][1][filters][1][operator]:eq
filter[filters][1][filters][1][value]:KIJos

Here is the code for the custom filtering:

var kendoGrid = $("#grid").data("kendoGrid");
var searchText = $("#tool-search").val();
var searchParts = searchText.split(",");
var search = { logic: "and", filters: [] };

search.filters.push({ field: "FacilityId", operator: "eq", value: _selectedFacilityId });

if (searchParts.length > 0)
search.filters.push({ field: "EntityCode", operator: "contains", value: $.trim(searchParts[0]) });

if (searchParts.length > 1)
search.filters.push({ field: "ProcessName", operator: "contains", value: $.trim(searchParts[1]) });

if (searchParts.length > 0)
kendoGrid.dataSource.filter(search);

kendoGrid.dataSource.pageSize(_selectedPageSize);
kendoGrid.dataSource.read();

Any help would be greatly appreciated.

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 08 Apr 2013, 04:12 PM
Hi Chris,

I am afraid that the provided information is not sufficient enough in order to determine where exactly the problem comes from. I tested the filter method in this sample page, but got everything to work as expected.

Could you please check my sample and let me know what I am missing or can you reproduce the issue in one of our demos? If not, could you please send me a small but runnable project which isolates the issue? In this way I would be able to examine your exact configuration and assist you further.
Thank you in advance for the cooperation.

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or