I have a question about the customizing the filter popup of the RadGridView.
The RadGridView is displaying a read-only list of document which have a type (integer), a name (string), a date (datetime) and a filepath (string). There is also an Enum which define the legal value for the document type (and store a string description). I use CellFormating event to convert the Integer value of the document type to the corresponding string description.
How could I change the Nodes in the Treeview of the Excel-like filtering popup to display the string description of the value ? (we should keep the integer value for the filterdescriptor of course)
The second one is a little bonus for me
Is it possible to build the treeview from the Enum instead of the default behavior ? (Having a node for each value in the enum and not only the value currently in the datasource of the gridview. Theses extra nodes could be displayed but greyed out).
Thanks for reading.
5 Answers, 1 is accepted
Thank you for contacting us.
You can customize the filter popup via the RadGridView.FilterPopupInitialized event and the RadListFilterPopup.PopupOpened event. Below is a sample code snippet, demonstrating how to replace the integer values for the 'Type' column with the converted enum value and display this value in the popup. As to the question about having tree node for each enum value in the filter popup, you can get all distinct values for the column and add the missing values.
Note that this is just a sample approach, which demonstrates the idea and it may not cover all possible cases. Feel free to modify it on a way, which suits your scenario best.
I hope this information helps. Should you have further questions, I would be glad to help.
Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).
Thank you very much for your very well documented answer (you could copy paste your post in the documentation), it's working pretty nice.
There is only one little issue.
If you have two node with the same text value (after the threenode manipulation), you will get in trouble when the final user will start playing with it. (First because your filter is a nonsense then because the app will crash)
I'm not concerned but someone else could run into it (testing the code with fake value, localization issue, ...).
Thank you for writing back.
I am glad that the provided answer is suitable for your case. However, the RadTreeNodes in the sample code snippet are generated from the enum values and it is not allowed to have two identical definitions. Note that the Excel-like filtering popup is intended to contain only the available values from the grid rows and it is not reasonable to have additional nodes by which you are not allowed to filter.
Please do not hesitate to contact us if you have any additional questions.
The additional nodes are just here to say "There is no document of this type in the list! Don't look for them".
You are right with enum which havn't two identical definitions. In my case I'm using an attribute description of the enum to store the text value (it's more flexible because it's a string and you don't have coding constraint) but these attribute have no constraint about unicity (It could append especially when you have globalization and you leave something like "missing traduction").
Of course that's a filter list with identical définitions (text or value) is not usable.
I'm just giving a warning about this for other people which may look at this post and use their own routine for building the filter.
Thank you for getting back to me.
I completely understand your point. However, it is a custom implementation for the RadListFilterPopup and all these possible specific cases should be handled by the developer according to his requirement. The nodes in the tree view should be distinguishable and it is up to you how to handle all of the specific scenarios, which are results from the custom logic.
Should you have further questions, I would be glad to help.