Trigger FilterMenuInit event after a row is added

4 posts, 0 answers
  1. Stu
    Stu avatar
    6 posts
    Member since:
    Apr 2015

    Posted 26 Aug 2015 Link to this post

    I'm building the list of values a column can be filtered by using the FilterMenuInit event and the initCheckboxFilter(e) javascript code and it's working great.

    Now I add a new row to the grid using the toolbar Create method and AJAX.  The new row might contain a value for the column being filtered that wasn't there before.  I would like to be able to add that new value to the existing list in the filter for that column.  Can I somehow set the FilterMenuInit event to be triggered again?

    Thanks,
    Stu

  2. eo
    eo avatar
    27 posts
    Member since:
    Jul 2015

    Posted 26 Aug 2015 in reply to Stu Link to this post

    Hello Stu,

    You can trigger the FilterMenuInit manually everytime a create request is executed by taking advantage of the onRequestEnd event. You can configure your MVC project to do so, like it was explained in this Telerik forum post. ​Furthermore, if you want this to happen only on create, you could limit it by using the type property like this:

    1.function onRequestEnd(e) {
    2.    if (e.type === "create") {
    3.        //YOUR LOGIC HERE
    4.    }
    5.  };

    Hope this helps!

  3. Stu
    Stu avatar
    6 posts
    Member since:
    Apr 2015

    Posted 27 Aug 2015 in reply to eo Link to this post

    Hi eo.  Thanks very much for your reply.  I put in the event for RequestEnd and it is firing and I can examine the event argument and see the type (create, read, etc.) and the data for the row just added.

    But I have no idea how to translate that into calling the FilterMenuInit function.  The arguments are totally different.  And to be honest, the JS code I got from this post (http://docs.telerik.com/kendo-ui/web/grid/how-to/checkbox-filter-menu) works, but I have no idea how (I'm a little new to JS and this code is pretty complex).  Can you either show me how I would take the event argument from RequestEnd and translate that into the argument passed into function initCheckboxFilter(e) from the article above.  Or the simpler thing would be to somehow tell the grid to clear the state such that the FilterMenuInit event would be called again for each column filter action.

    Thank you.

  4. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2035 posts

    Posted 31 Aug 2015 Link to this post

    Hello Stu,

     

    Indeed the filterMenuInit event is fired when the grid filter menu is initialized, when it is opened for the first time.

     

    I think that easier solution would be accessing the menu container and manipulate its child elements ( add, remove or modify) rather than triggering the filterMenuInit event each time when a new row is added. 

     

    In the following forum thread you can find a sample solution how to access the filterMenu container using the th element of the column. 

     

    Regards,
    Boyan Dimitrov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top