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

MultiSelect remove selected item event handling?

5 Answers 4332 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 07 Aug 2013, 07:28 PM
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

5 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Nikolov
Telerik team
answered on 08 Aug 2013, 08:09 AM
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!
0
Dan
Top achievements
Rank 1
answered on 08 Aug 2013, 02:37 PM
Thanks very much for the quick response! This will work for me
0
Kiril Nikolov
Telerik team
answered on 08 Aug 2013, 02:50 PM
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!
0
Hugo Esperanca
Top achievements
Rank 1
answered on 29 Aug 2013, 01:04 PM
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
0
Hugo Esperanca
Top achievements
Rank 1
answered on 29 Aug 2013, 01:20 PM
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
Tags
MultiSelect
Asked by
Dan
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Dan
Top achievements
Rank 1
Hugo Esperanca
Top achievements
Rank 1
Share this question
or