Articles in this section
Category / Section

How to remove group of items from Listview

1 min read

How to remove Group of Items from ListView?

We can remove the multiple Items from ListView using removeMultipleItems API.  In below sample we removed group of list items based on its category.

Follow below steps to achieve this,

  • Use dataManager to filter the list items based on category.
  • And pass the filtered data for removeMultipleItems API to remove the list items from ListView.

 

 Refer to the below code snippet

//Initialize ListView component

var grpListObj = new ej.lists.ListView({

 

    //Set defined data to dataSource property

    dataSource: cars,

 

    //Map the appropriate columns to fields property

    fields: { groupBy: 'category', text: 'columntext', id: 'columnid' },

 

    select: onSelect

 

});

 

//Render initialized ListView component

grpListObj.appendTo('#listview-grp');

 

function onSelect(event){

var value = event.data.category;

var data = new ej.data.DataManager(cars).executeLocal(

new ej.data.Query().where("category", "equal", value, true)

); // Filter the list items by its category

if (value) {

 grpListObj.removeMultipleItems(data); // Remove the filtered data

 

}

}

 

 

Refer to the below sample link

Sample

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied