In Code

You can delete List items in code in the following ways.

  • By index
    Pass the index to the deleteItem(itemIndex) method. If the List is grouped, this method should be given an object with the indexes of the group and the item to be deleted.

    JavaScript
    var list = $("#listContainer").dxList("instance");
    // Deletes the item with index 1 
    list.deleteItem(1);
    // Deletes the item with index 0 from the group with index 2
    list.deleteItem({ group: 2, item: 0 });
  • By DOM node
    Pass the DOM node to the deleteItem(itemElement) method.

    JavaScript
    var list = $("#listContainer").dxList("instance");
    // Finds all List items
    var itemNodes = $("#listContainer").find(".dx-list-item");
    // Makes the first item the last
    list.deleteItem(itemNodes[itemNodes.length-1]);

NOTE: If you want to delete an item by key or by data object, do it directly in the data source.

See Also