Restrict and customize filter menu based on dynamic field attribute

4 posts, 0 answers
  1. Alex
    Alex avatar
    31 posts
    Member since:
    Jun 2011

    Posted 30 Nov 2012 Link to this post

    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?
  2. Marin
    Admin
    Marin avatar
    1045 posts

    Posted 05 Dec 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alex
    Alex avatar
    31 posts
    Member since:
    Jun 2011

    Posted 10 Dec 2012 Link to this post

    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.
  5. Marin
    Admin
    Marin avatar
    1045 posts

    Posted 13 Dec 2012 Link to this post

    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.
Back to Top