Get index of item in grouped kendo grid MVVM

2 posts, 0 answers
  1. Neeraj
    Neeraj avatar
    139 posts
    Member since:
    May 2015

    Posted 29 Nov 2018 Link to this post

             I have kendo mvvm grid which is grouped .  How can i delete item from grid easily?

    Below is code to delete item from grid i found from various sources, in that 'index' gives incorrect number after grid is inserted or deleted with other items later on

    var tstgrid = $(e.currentTarget).closest("[data-role='grid']").data("kendoGrid");
    var index = tstgrid.items().index(;
    ImportPNRPricingViewModel.Tsts._data.splice(index, 1);


    to insert we, use $.merge, 'ImportPNRPricingViewModel' is my observable and 'response' has new items





  2. Stefan
    Stefan avatar
    3067 posts

    Posted 03 Dec 2018 Link to this post

    Hello, Neeraj,

    Thank you for the code.

    I can assume that the difference occurs because the listed method is getting the index of the row not the dataItem in the data array. When the Grid is grouped, the array order is often different.

    I made an example which shows how to get the item index based on the current row and based on the data array:

        var tstgrid = $("[data-role='grid']").data("kendoGrid");
        var dataItem = tstgrid.dataItem(;
        var indexItem = tstgrid.dataSource.indexOf(dataItem);
        var indexRow = tstgrid.items().index(;

    I hope this is helpful.

    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top