Imagine you want a filter to show only rows with "name" containing "Jennie" or "name" containing "Genie".
Trying this yields no matches:
myPeopleDataSource.filter([{field:"name",operator:"contains",value:"Jennie"}, {field:"name",operator:"contains",value:"Genie"}])
I'm guessing this is because the filter is limited to one criteria per field per filter action.
Is that true?
Any way around this?
12 Answers, 1 is accepted
Indeed, the or filtering is possible, however the format of the filter descriptor should be similar to the following:
{
logic:
"or"
,
filters: [
{field:
"name"
,operator:
"contains"
,value:
"Jennie"
},
{field:
"name"
,operator:
"contains"
,value:
"Genie"
}
]
}
All the best,
Rosen
the Telerik team
Sadly in my case I need to mix AND and OR.
What if I need all records where ("name" contains "Jennie" OR "Genie") AND ("grade" equals "7")?
Is there a way to do that? Can I filter twice cumulatively? Build a hierarchical filter? Or is there a custom filter function I can provide? Or something else?
Help me, Obi Wan!
You should nest the expressions. For example:
{
logic:
"and"
,
filters: [{
logic:
"or"
,
filters: [
{field:
"name"
,operator:
"contains"
,value:
"Jennie"
},
{field:
"name"
,operator:
"contains"
,value:
"Genie"
}
]
},
{ field:
"grade"
,operator:
"eq"
,value: 7 } ]
}
All the best,
Rosen
the Telerik team
I've actually coded a surprisingly playable Nintendo 64 emulator using only the Kendo data filter language.
Which brings me to my question:
does anybody have a Super Mario World ROM image in json format?
var
filter = {
logic:
"or"
,
filters: [
{
field:
"LastName"
,
operator:
"startswith"
,
value: text.toLowerCase()
},
{
field:
"FirstName"
,
operator:
"startswith"
,
value: text.toLowerCase()
},
{
field:
"OrganizationName"
,
operator:
"startswith"
,
value: text.toLowerCase()
}
]
}
I'm afraid that I'm unable to observe such behavior locally. I have attached a screenshot which shows the created structure which maps to the expression you have provided.
Greetings,Rosen
the Telerik team
LastName~startswith~'a'~or~FirstName~startswith~'a'~or~OrganizationName~startswith~'a'
Looks good so far.... However, when MVC gets ahold of it i see picture "ONE" as attached.... it drops OrganizationName altogether..
If i change the filter to read this way:
var
filter = [{
logic:
"or"
,
filters: [
{
field:
"LastName"
,
operator:
"startswith"
,
value: text.toLowerCase()
},
{
field:
"FirstName"
,
operator:
"startswith"
,
value: text.toLowerCase()
},
]
},
{
field:
"OrganizationName"
,
operator:
"startswith"
,
value: text.toLowerCase()
}]
(LastName~startswith~'a'~or~FirstName~startswith~'a')~and~OrganizationName~startswith~'a'
And attached picture TWO is the result in the DataSourceRequest object.
Notice the "AND" in the last half of the equation.
I am on v2012.3.1114 if that makes a difference. No matter which way i send data, i can't seem to get the DataSourceRequest to read you have in your screenshot. Please help. Thanks.
Could you please provide a small sample in which the behavior can be observed locally.
Regarding the second construct, indeed this is expected. The default value of the logic field is and, thus as with your example, when it is omitted this value is used.
Rosen
the Telerik team
Hi Rosen.
I am stuck how to get this LOGICfiltering concept in c#?
I want all (single, composite KENDO filter) to be converted into a string formatted statement, so that I can pass it as Dynamic query statement in SQL to stored Proc?
can it be done?
I just want colname, colvalue, operators value I will loop it and make SQL statement//
EX: colname 'startswith' colvalue and/or colname 'endswith' colvalue and so on...
Hello,
My suggestion is to take a look at the Ajax Binding article and specifically the sections where DataSourceRequest object and ToDataSourceResult method are explained. The DataSourceRequest object contains the information about the page, sort and etc expressions applied. The ToDataSourceResult method is building expression trees so Entity Framework to create and execute sql queries against the data base.
Regards,Boyan Dimitrov
Progress Telerik