How to remove selected elements from multi list view?

2 posts, 0 answers
  1. Manan
    Manan avatar
    5 posts
    Member since:
    Apr 2014

    Posted 22 Apr 2014 Link to this post

    Please tell me how can we remove element from multi listview. When i am selecting any item it is giving me value but i am unable to remove selected elements.

    PSB code:

    var data = [
        { id: 1, text: "text 1" },
        { id: 2, text: "text 2" },
        { id: 3, text: "text 3" }
    ];


    var d = $("#listview").kendoListView({
        dataSource: data,
        template: kendo.template($("#template").html()),
        selectable: "multiple",
        change: function() {
            var index = this.select().index(),
                dataItem = this.dataSource.view()[index];
      
            //log("id: " + dataItem.id + ", text: " + dataItem.text);
            var selected = $.map(this.select(), function(item) {
                return data[$(item).index()].id;
                   });
            //data.remove(selected);
            //console.log(data);
            console.log(selected);
            //console.log("[" + selected.join(", ") + "]");
        }
    });


    Please see jsfiddle : http://jsfiddle.net/AAMLA/179/
  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 24 Apr 2014 Link to this post

    Hi Manan,

    This could be achieved by using the ListView's dataSource.remove method. For example: 
    change: function() {
        var index = this.select().index(),
            dataItem = this.dataSource.view()[index];
        this.dataSource.remove(dataItem);
    }

    Regards,
    Alexander Popov
    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
Back to Top