I have a radgrid I am using to hold data about client interests likes and dislikes. I need the user to be able to filter the results. I was using radfilter, and it works, but is very complicated for the end user and is too confusing. I thought that the way it is set up in the rad grid itself may be easier.
Though from what I can tell, I can only do one expression at a time. I cannot do "and" and "or" expressions. Say I wanted to see who likes TV-Cartoon and who likes TV-Outdoors. Is there a way I can make BOTH of those appear?
As far as I can tell, you can only type one thing in the text box, use the filter drop down (I just used contains) and have that one expression show. Is there a way to do multiple?
8 Answers, 1 is accepted
The Excel-Like filtering functionality of the grid has the option to filter using multiple values (e.g. Value1 AND Value2). Please check out the Grid - Excel-like Filtering demo to see it in action.
Additionally you can check out the following articles that could be helpful to achieve the described behavior::
- Custom Filter Options with Handling
- Filter Template and Custom Columns
- Besides the built-in functionalities, you can also try to build/modify the filter expressions manually. Instructions are described in the Operate with the FilterExpression Manually
- Or modify the filter options: Custom Filter Options with Handling
I apologize, I have missed out one of the most important articles. That is the Header Context Menu. By getting familiar with the article, you will be able to change the HeaderContextMenu options and add/change/remove items as necessary.
Then you can use the custom filtering options/items in combination with the FilterCommand described in the Custom Filter Options with Handling you can apply any kind of filtering.
- Fire command Server-Side: https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/control-lifecycle/how-to-fire-command-events
- Fire command Client-Side: https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/client-side-programming/gridtableview-object/methods/filter
Manipulating the FilterExpressions described in the Operate filter expressions article I've shared earlier may be an simpler approach. RadFilter does not even have to be used.
Create the Controls that will be used for filtering (similar to those from the picture you have shared)
Create the Grid and set the AllowFilteringByColumn property to true to enable the filtering, and IsFilterItemExpanded property to false, to hide the Filter row.
When clicking the Filter button of each filtering criteria:
Filter using Value1 "OR" Value2
Filter using Value1 "AND" Value2
Clear the Filter:
Attached you can find a WebForms page demonstrating this scenario. Please download and test sample to see if that is what you are looking for. The code is fully runnable, you can either import the page into a Web Site project or copy its source code.
I also should have been more specific. I do not want the same thing every time in the text boxes. Just the same set up, and filtering per line.
So one should be able to do:
individual likes __________(text box) OR ____________(text box) (button here)
and put whatever they need in each box. One time, it could be likes cats OR dogs. Another time, parrots OR pigs. The text boxes will change depending on what exactly they want to filter; the filtering itself (this or that) should stay prebuilt and the same. The possibility of interests will be a couple hundred long possibly. There is no way to guarantee that cats OR dogs would be a popular search every time the web form is loaded. But needing to filter by "anything" or "anything" is.
I apologize, I was not aware of your preferred coding language.
Below I will share the VB version of the code:
The text for each textbox was pre-populated for testing purposes. You can remove them easily by removing the Text properties of each TextBox control.