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

Restrict and customize filter menu based on dynamic field attribute

3 Answers 43 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 01 Dec 2012, 03:21 AM
Sorry to post again, but I had thought I had figured this out...turns out not.

Again, I have a RadFilter built up of fields pulled dynamically from a table.  An attribute in that table indicates the type of field from which I can derive the available filter menu options.  For example, CustomerName is a text field so it should have Contains, but not GreaterThan.  To a degree this can be controlled by the DataType field of the FieldEditor.  However, I want all my data types to be strings for processing sake.

I have gone over the demo with the RadCombo that replaces the control and I have a similar situation where the dynamic field can be driven by a dynamic list of valid values.  What DataType should be used for that if I were to use DataType to constrain the options (doesn't appear to be one).

Further, I have seen the examples of using JavaScript to customize the menu, but every one of them relies on either DataType or FieldName.  Again, neither of those work for me because one is constant and the other varies for each field.

Also, I may be able to rename, through the Localization properties, some of the menu options, but is there a way to add additional ones?

Any leads on a direction?

3 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 05 Dec 2012, 12:37 PM
Hello,

 The context menu in RadFilter is a shared control which holds all available options in its items and only the necessary ones are shown when you click on a button according to the data type of the field. That's why any modifications regarding showing and hiding of items in the menu should be done on the client at the point when the menu is showing for a particular field. If you know for which field exactly the menu is about to show you can handle its shown event and modify the visibility of the items according to your needs. If every field requires different options in the menu then this information should also be available on the client (for example you can serialize it from the server).
Currently RadFilter does not provide an easy way of manipulating the items in the context menu, that's why custom client-side approaches are required to achieve the desired effect. For more information you can refer to the client-side APIs for RadFilter and RadContextMenu:
http://www.telerik.com/help/aspnet-ajax/filter-getting-familiar-with-client-side-api.html
http://www.telerik.com/help/aspnet-ajax/menu-client-side-objects.html

Kind regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Alex
Top achievements
Rank 1
answered on 10 Dec 2012, 11:55 AM
To confirm, this means that I would have to store (from the server side) an object that is accessible to the client-side that contains a mapping of the field names in the filter to my key that would determine which of the conditions should be shown.  In addition, if I need to have conditions that do not exist in the pre-existing list I would need to use the client-side methods to create them.  Sound correct?

  I believe a lot of this would be a much easier done if there had simply been an additional member in the RadFilterDataFieldEditor object where I could store a string that could be referred to in the client-side.  My actual implementation I had to encode the "type" of field in the FieldName member so that it was easily accessible by the client-side FilterCreated method and then remove this decoing when parsing through the tree.
0
Marin
Telerik team
answered on 13 Dec 2012, 10:00 AM
Hello,

 Yes, currently this is the recommended approach. Indeed it involves a lot of custom code and adjustments. We will consider improving the RadFilter API to make such tasks easier to achieve.

Best regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Filter
Asked by
Alex
Top achievements
Rank 1
Answers by
Marin
Telerik team
Alex
Top achievements
Rank 1
Share this question
or