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

How to remove selected elements from multi list view?

1 Answer 407 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Manan
Top achievements
Rank 1
Manan asked on 22 Apr 2014, 10:06 AM
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/

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 24 Apr 2014, 07:33 AM
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!
 
Tags
ListView
Asked by
Manan
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or