Filter menu events not invoke for RadGrid FilterType of "HeaderContext"

4 posts, 0 answers
  1. Rob
    Rob avatar
    8 posts
    Member since:
    Dec 2014

    Posted 22 Jan Link to this post

    Hi,

    I have a RadGrid with filters. The FilterType is "HeaderContext".
    I have restricted the filter options contained in the drop down list according to the field type.
    For example, for a numeric field, I use options "GreaterThan", "LessThan"  etc. For a string, I use options "Contains", "StartsWith" etc.

    To achieve this, I use the following:

    <ClientSettings>
                        <Scrolling AllowScroll="false" />
                        <ClientEvents OnFilterMenuShowing="FilterMenuShowing" />
                    </ClientSettings>
                    <FilterMenu EnableImageSprites="False" OnClientShowing="MenuShowing" />

    However, these events are not invoked when the value RadGrid's FilterType is "HeaderContext".
    This means that for each data type, the filter option drop down list contains all options, many of which are irrelavant.

    Please can you offer some assistance that will enable me to restrict the filter options contained in the DropDownList where the FilterType of the RadGrid is "HeaderContext".

     

    Thanks,

     

    Rob

  2. Attila Antal
    Admin
    Attila Antal avatar
    202 posts

    Posted 25 Jan Link to this post

    Hi Rob,

    For the HeaderContextMenu, try using the OnHeaderMenuShowing client event which is fired before the header context menu is rendered.:

    <ClientSettings>
        <ClientEvents OnHeaderMenuShowing="OnHeaderMenuShowing" />
    </ClientSettings>

    The other events you have tried are applicable for the basic filter menu. You can check out the following demo to see the basic filtering: Grid - Basic Filtering

    Kind regards,
    Attila Antal
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Rob
    Rob avatar
    8 posts
    Member since:
    Dec 2014

    Posted 08 Feb in reply to Attila Antal Link to this post

    Hi Attila,

    Thank you for replying.

    I have already tried OnHeaderMenuShowing, and it does not work. In fact, I get an error (See attached). This is because I need to get the column from the event args as shown below.

    function OnFilterMenuShowing(sender, eventArgs) {         
        // I can get the column
            column = eventArgs.get_column();
    }

    function OnHeaderMenuShowing(sender, eventArgs) {

        // I cannot get the column
        //JavaScript runtime error: Object doesn't support property or method 'get_column'
        column = eventArgs.get_column();
                
    }

    Once I have got the column, I can then get the column data field "column.get_dataField()". Once I have got the data field, I can then determine which filter options to hide and show.

    I can get the column from onFilterMenuShowing, however I cannot get it from OnHeaderMenuShowing. If you could let me know how I can get the column from the event args of OnHeaderMenuShowing,
    that would really help.

    Thanks,

    Rob
  4. Attila Antal
    Admin
    Attila Antal avatar
    202 posts

    Posted 3 days and 18 hours ago Link to this post

    Hi Rob,

    The method to get the column name in this event is called get_gridColumn(). Please check out the OnHeaderMenuShowing

    function OnHeaderMenuShowing(sender, eventArgs) {
        column = eventArgs.get_gridColumn();
    }

    Sometimes, if you are not sure, you can debug it yourself very easily by using the Browser's developer tools. I highly recommend checking out the Improve Your Debugging Skills with Chrome DevTools blog post which can serve as a guide when debugging an application on client side.

    I hope this will help resolve the issue.

    Kind regards,
    Attila Antal
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top