Show the destroyed data - e.fetch is not a function

2 posts, 0 answers
  1. Chris
    Chris avatar
    59 posts
    Member since:
    Oct 2015

    Posted 11 Apr Link to this post

    HI

    How could I show the destroyed data in another Grid ?

    I have met an error : 

    grid2.setDataSource(grid.dataSource._destroyed);

    Uncaught TypeError: e.fetch is not a function at init.setDataSource (kendo.all.min.js:48)


    Best regards

    Chris

     

  2. Tsvetina
    Admin
    Tsvetina avatar
    2102 posts

    Posted 13 Apr Link to this post

    Hello Chris,

    The setDataSource method of the Grid accepts a DataSource instance as an argument. The _destroyed collection is an array, so you should not pass it directly. If what you are trying to do is display deleted items while doing Batch editing in the Grid, my advice is to go with the following cleaner approach.

    1) Handle the Grid remove event.
    @(Html.Kendo().Grid(Model)
          .Name("grid")
          .Events(e => e
              .Remove("grid_remove")
          )
    )

    2) In the remove event, get the currently deleted item and add it to the second Grid:
    function grid_remove(e){
      var item = e.model,
        grid2= $("#grid2").data("kendoGrid");
     
      grid2.dataSource.add(item.toJSON());
    }

    I am using toJSON method of the model to get only the clear data, without the Model properties.

    Here is a sample client-side implementation for your reference:
    http://dojo.telerik.com/@tsveti/asIna/5

    Regards,
    Tsvetina
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top