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

How to prevent multiselect from deleting items?

5 Answers 774 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Internal Licensing
Top achievements
Rank 1
Internal Licensing asked on 12 Oct 2015, 11:22 AM

I use the functionality of the multiselect to add or remove items, but I need a confirmation before an item will be deleted.

So I use the DataBound-Event to save the current values an everytime the Change-Event is triggered I compare the current values against the previous:

 function onChange() {
        var previous = this._savedValues;
        var current = this.value();
        if (current.length < previous.length) {
            var diff = $(previous).not(current).get(0);
            if (diff != null) {
                var memberName = diff.substring(diff.indexOf('CN=') + 3, diff.indexOf(','));
                var string = 'Delete' +  memberName + '?';
                if (confirm(string.replace('{0}', memberName))) {
                    console.log("confirmed"); // nothing more happens here
                }
                else {
                    //reset;
                    this.value(previous);
                }
            }
        }
        saveCurrent(this);
    } 

    function saveCurrent(multi) {
        multi._savedValues = multi.value().slice(0);
    } 

    function onDataBound() {
        saveCurrent(this);
    }​

The problem is: This doesn't really work properly. If I add and remove some items, the multiselect deletes more items than I want to remove. 

 

5 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 14 Oct 2015, 07:23 AM

Hello Oliver,

 

I am afraid that currently such functionality is not supported as the change event is not preventable. You can submit this as a feature request on UserVoice, so that it is considered for implementation in a future release.

 

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
Internal Licensing
Top achievements
Rank 1
answered on 16 Feb 2016, 08:18 AM

It is possible to Add or Insert an item programmatically?

I store the deleted item from dataItems but I cannot Add or Insert the item. 

0
Kiril Nikolov
Telerik team
answered on 17 Feb 2016, 12:26 PM
Hi Oliver,

You can use the corresponding dataSource methods for that:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods

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
Mike
Top achievements
Rank 1
answered on 12 Jul 2016, 07:29 PM

QUOTE>I am afraid that currently such functionality is not supported as the change event is not preventable. You can submit this as a feature request on UserVoice, so that it is considered for implementation in a future release.

 

Has this functionality been added yet?

0
Kiril Nikolov
Telerik team
answered on 13 Jul 2016, 07:20 AM
Hi,

The functionality is not yet added, as the UserVoice item was not up voted enough to be prioritized over other suggestions. Please feel free to up vote that suggestion.

Regards,
Kiril Nikolov
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
MultiSelect
Asked by
Internal Licensing
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Internal Licensing
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Share this question
or