I define my operators in the following way, and the default operator is Is Equal To. I would like to have Contains as my default operator.
filterable: {
extra:
false
,
//do not show extra filters
operators: {
// redefine the string operators
string: {
contains:
"Contains"
,
startswith:
"Starts With"
,
eq:
"Is Equal To"
}
}
}
4 Answers, 1 is accepted
I am afraid this is not supported out of the box, by default the selected operator is "eq". As a workaround you could manually select the drop down item after the filter menus are rendered. For example:
dataBound:
function
(e) {
//get the dropdowns
var
dropDowns = $(
".k-filter-menu"
).find(
"[data-role=dropdownlist]"
);
//select the first element as defined in the filterable configuration
setTimeout(
function
() {
dropDowns.eq(0).data(
"kendoDropDownList"
).select(0);
//select the first option
dropDowns.eq(0).data(
"kendoDropDownList"
).trigger(
"change"
);
//trigger the change
});
}
Unfortunately if you decide to use this approach, you will have to hard code the drop down index. As a general information, the select list options will be ordered in the same way as they are defined in the filterable configuration.
I hope this helps.
Regards,
Alexander Valchev
the Telerik team
I need the same things as Ross did. " I need all columns in my grid filter to default to "contains""
Is this feature available yet?
If not, is there any work around solutions?
Thank you,
Alex Nguyen
I am glad to inform you that the issue is fixed in the latter release. Please download Kendo UI v2013.1.514 or newer and give it a try.
Regards,
Alexander Valchev
the Telerik team
Thank you for the quick reply. Is there any document/instruction how to achieve it? Is there any sample code available?
Thank you,
Alex
Corresponding documentation could be found at the following link:
Regards,
Alexander Valchev
Telerik
columns.Bound(c => c.Title)
.Filterable(filter=>filter
.Extra(false)
.Operators(o=>o.ForString(f=>f.Contains("Contains"))))
In MVC wrappers you should call the .Clear() method at first.
Regards,
Alexander Valchev
Telerik
Your jsbin example doesn't work in IE10. When you click to expand the combo, it collapses immediatly.
Kind Regards
Oscar.
I believe that the issue is caused by the jsBin itself. The issue does not occur when you view the same sample in a full screen result screen:
Regards,
Alexander Valchev
Telerik
Thank you very much, Alexander.
I tried the same thing with the new filter row option, but it does not work. Here is an example: http://jsbin.com/sopeteju/1/
Is there a workaround for this problem?
Best,
Igor
In case you are using the new filter row feature you should specify the default cell operator explicitly.
Please check the updated code sample: http://jsbin.com/xusim/1/edit
Regards,
Alexander Valchev
Telerik
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str
.Clear()
.Contains("Contains")
.DoesNotContain("Does not contain")
.StartsWith("Starts with")
.EndsWith("Ends with")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to")
)
)
)
Unfortunately the filter list is displayed the the default order, not the order I specified. If I change anything about one of the filters (e.g., add a trailing space) then I get the order I specified.
http://jsbin.com/zeqocamora/1/edit
I'm doing something like below to set contains as default filter:
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.Contains(Strings.FilterContains)
.StartsWith(Strings.FilterStartswith)
.IsEqualTo(Strings.FilterIsEqualTo)
.IsNotEqualTo(Strings.FilterIsNotEqualTo)
))
)
But it doesn't work in IE. please help asap.
Thanks,
Yadwinder
problem because I updated several of them at the same time but I suspect it’s the stylesheet files because if I remember correctly, after updating all javascript files, I still had the problem. So I recommend that you update the stylesheet files first to see if it fixes your issue. Anyway, here’re the files that I updated.
Kendo.all.min.js
Kendo.aspnetmvc.min.js- v2012.2.710
Kendo.dataviz.min.css- v2013.1.514
Kendo.default.mn.css - v2013.1.514
Kendo.common.min.css- v2013.1.514
Then I have my code
like this:
.Filterable(f => f
.Extra(true)
.Operators(o=> o
.ForString(s => s
.Clear()
.Contains("Contains")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to")
.StartsWith("Starts with")
.EndsWith("Ends with")
))
.Cell(cell
=> cell.Operator("Contains")))
;
I tried this on a Grid and found it worked successfully to list the operators in the order specified, with the first (contains) being the default:
.Filterable(filter => filter
.Operators(op => op
.ForString(s => s
.Clear()
.Contains(
"Contains"
)
.DoesNotContain(
"Does not contain"
)
.IsEqualTo(
"Is equal to"
)
.IsNotEqualTo(
"Is not equal to"
)
.StartsWith(
"Starts with"
)
.EndsWith(
"Ends with"
)
.IsNullOrEmpty(
"Is empty"
)
.IsNotNullOrEmpty(
"Is not empty"
))
))
I tried what appears to be the equivalent for the Filter control:
.Operators(o =>
{
o.String(s =>
{
//s.Clear();
s.Contains(
"Contains"
);
s.Doesnotcontain(
"Does not contain"
);
s.Eq(
"Is equal to"
);
s.Neq(
"Is not equal to"
);
s.Startswith(
"Starts with"
);
s.Endswith(
"Ends with"
);
s.Isnullorempty(
"Is empty"
);
s.Isnotnullorempty(
"Is not empty"
);
});
})
While there aren't any errors, and I can customize the text that is displayed for the Filter component's operators, it doesn't appear that this can be used to control the order in which the operators are displayed on-screen (and the first one listed doesn't become the new default operator). Can anyone confirm that this is in fact how this is supposed to work, and this nearly identical feature works differently when used in a Grid control compared to the Filter control? Or am I by chance just missing something that is causing the inconsistent behavior?
Hello Aaron,
Indeed the behavior is not expected and the order should be preserved. We have it logged to our backlog and we will do our best to fix it as soon as possible.
You can track the status of the issue in the link below:
We apologize for the inconvenience this might have caused you and thank you for your understanding.
Regards,
Georgi
Progress Telerik
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).
Thanks for the update, and for creating the issue on GitHub!
Any idea as to when (or if) this might be resolved? I'm not looking for a hard date to hold you to or anything, I'm just curious if it's fairly safe to assume that this will be addressed within the next 6-12 months (or if this is merely an acknowledgement of the issue but it could go unresolved for years).
Hi Aaron,
My name is Tsvetomir and I would like to inform you that the issue is undergoing active development. I cannot provide an exact date for its release, however, expect it to be in any of the upcoming releases.
Kind regards,
Tsvetomir
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hi Srinivasulu,
Based on the provided information, I am not completely sure what the end solution should look like. Also, I am uncertain what would the requirement and when the condition should be executed.
Is it possible for you to take a few moments and share more information on the exact scenario you are willing to achieve? Sharing a short video and/or screenshots would be of great help.
Looking forward to your reply.
Regards,
Tsvetomir
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.