Completed
Last Updated: 11 May 2016 06:58 by ADMIN
Tim R
Created on: 10 Jan 2013 13:28
Category: Kendo UI for jQuery
Type: Feature Request
15
grid public API needs addItem() method to PROGRAMMATICALLY insert a new item (i.e. a fully populated new row)
At present there is no method in the grid's public API to insert an item (i.e. fully populated new row) into the grid programmatically, that is, as distinct from visual edit mode using addRow().  

There are methods to update the dataItem, and to remove an item, but no counterpart method to add an item exists. 

There are many use cases for this method; for one possible use case, please see this thread:

http://www.kendoui.com/forums/ui/grid/how-to-append-a-row-programmatically-not-in-edit-mode.aspx#2442552

For my purposes, it would be optimal if the requested addItem() method did not destroy the UI state of expanded/collapsed groups.

After it has been inserted, the item needs to behave exactly like all of the other rows in the grid: it should be "observed"; it should have a data-UID; it should have a corresponding dataItem; be included in grouping, sorting, filtering, etc etc.
6 comments
ADMIN
Petyo
Posted on: 11 May 2016 06:58
Preserving the collapsed/expanded state may be achieved using this how-to (check the others in the category, too):

http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/persist-expanded-rows
ADMIN
Telerik Admin
Posted on: 23 May 2014 11:21
The original request concerns adding grid items programmatically, as far as I understand. The preservation of the expanded/collapsed state is a detail included in it. 

If this is what's remaining as a query from your end, I am reopening this thread for this part of it in particular.
Tim R
Posted on: 22 May 2014 13:43
The grid is not "stateful" with respect to expanded/collapsed groups.  Adding a row to the underlying data destroys the expand/collapsed state.   I need a way to add rows while PRESERVING the expand/collapse state..
Tim R
Posted on: 22 May 2014 13:41
I wish you guys would read more carefully. You haven't understood what I'm trying to accomplish. Please read my Use Case in the link I provided.
ADMIN
Jeff Valore
Posted on: 08 Apr 2013 16:28
If your grid is backed by a DataSource, you can just insert your populated item into the DataSource and the grid will update. However that will reset the expanded/collapsed state of the groupings. I think there was a StackOverflow post somewhere about a way to preserve the group expansion states between refreshes.
Tim R
Posted on: 10 Jan 2013 13:33
P.S. When the item is added, it should be sorted to the correct row-posiition, and appear in the correct group, if grouping is in effect.