MultiSelect remove selected item event handling?

6 posts, 1 answers
  1. Dan
    Dan avatar
    6 posts
    Member since:
    May 2013

    Posted 07 Aug 2013 Link to this post

    Hi
    I'd like to be able to respond when the user clicks the small x to remove a selected item from the multi select. I see the change Event but I don't know how to tell what triggered it (ie was it from a delete?) because that event fires both when items are added and removed.

    any help / sample snippet code would be greatly appreciated.

    Thanks
    Dan
  2. Answer
    Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2564 posts

    Posted 08 Aug 2013 Link to this post

    Hello Dan,

    In the change event function you can check if an item was removed and then execute custom logic based on this. In order to check if item is removed you can compare the content before and after the change event is fired. I have created an example showing a possible implementation:

    http://jsbin.com/aduvob/1/edit
     
    Regards,
    Kiril Nikolov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Dan
    Dan avatar
    6 posts
    Member since:
    May 2013

    Posted 08 Aug 2013 Link to this post

    Thanks very much for the quick response! This will work for me
  5. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2564 posts

    Posted 08 Aug 2013 Link to this post

    Hello Dan,

    I am glad that you are happy with the proposed solution. If you need anything else, do not hesitate to contact us.

    Regards,
    Kiril Nikolov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Hugo Esperanca
    Hugo Esperanca avatar
    5 posts
    Member since:
    Oct 2009

    Posted 29 Aug 2013 Link to this post

    Hi Kiril,

    Unfortunately your solution doesn't work the first time you run the code after the page is loaded because the value of the saveOld variable is undefined. Any possible alternatives?

    Many Thanks,
    Hugo
  7. Hugo Esperanca
    Hugo Esperanca avatar
    5 posts
    Member since:
    Oct 2009

    Posted 29 Aug 2013 Link to this post

    Just found the answer to my last issue. You just need to initialise the _saveOld variable on the dataBound event. Like this:

    dataBound: function () {
       var current = this.value();
       this._savedOld = current.slice(0);
    }
    I hope that this helps someone with the same problem.

    Regards,
    Hugo
Back to Top
Kendo UI is VS 2017 Ready