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

[Solved] "Ghost data" appears in kendoGrid when adding new row

1 Answer 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Laszlo
Top achievements
Rank 1
Laszlo asked on 10 Mar 2015, 09:29 AM
Hi,

If you repeat exactly these steps (example: http://dojo.telerik.com/OziZa):

- initialize grid with some data (done at load time or by pressing the "2014 data" button)
- re-initialize grid with empty data (press the "2015 data" button)
- disable sorting and add new row (press "Add row" button)

you will find that "ghost data" will emerge below the freshly inserted row. Actually, they are the rows from the first ever dataset the grid the have been initialized with.

I narrowed it down that it happens only if the current datasource is empty and the sorting is disabled. I disable sorting because I want to make sure the new row always appear on the top of the grid regardless how the grid columns were sorted beforehand.

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 12 Mar 2015, 07:51 AM
Hello Laszlo,

The behavior you have described is caused by the fact that the DataSource will ping the transport when empty and its fetch method is called. This in your case will repopulate the DataSource with its initial data, as this is what is supplied to the local transport, when DataSource is initialized. In order to workaround this you could initialize the DataSource with empty data and populate it after the fact, similar to the following:

$(document).ready(function () {
    $("#grid").kendoGrid({
        dataSource: {
            data: [],
            pageSize: 3
        },
        autoBind: false,
             /*...*/
   });
   set2014();
});


Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Laszlo
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or