How to prevent multiselect from deleting items?

6 posts, 0 answers
  1. Oliver
    Oliver avatar
    3 posts
    Member since:
    Jul 2013

    Posted 12 Oct 2015 Link to this post

    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. 

     

  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 14 Oct 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Oliver
    Oliver avatar
    3 posts
    Member since:
    Jul 2013

    Posted 16 Feb in reply to Kiril Nikolov Link to this post

    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. 

  5. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 17 Feb Link to this post

    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!
     
  6. Mike
    Mike avatar
    1 posts
    Member since:
    Oct 2013

    Posted 12 Jul in reply to Kiril Nikolov Link to this post

    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?

  7. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 13 Jul Link to this post

    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.
     
Back to Top
Kendo UI is VS 2017 Ready