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

Inserted Item Moves To Top After Save Or Another Add

2 Answers 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 28 Jan 2013, 04:23 PM
I have a question about Kendo Grid for ASP.NET MVC.  It's probably something that I'm not doing incorrectly.

When I add a new item to the grid, I'm using the solution described on this forum post to move the inserted <tr> to the bottom of the grid.  That part works fine.  However, when I save the changes to the grid or add a new item, the inserted item is moved to the top of the grid, even if that breaks the currently applied sort order.

I have attached a simple project that demonstrates this.  To repro what I'm talking about, do the following:
  1. Run the app
  2. Note that the grid is currently sorting on the Id column in ascending order
  3. Go to the last page
  4. Click the "Add New Item" 
  5. Set the Id to 550 and enter First Name, Last Name, and Position
  6. Click "Save Changes" or "Add New Item"
  7. The inserted row that was at the bottom of the grid has been moved to the top, ignoring the sort order
Can anyone point out what I'm doing wrong?

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 30 Jan 2013, 12:07 PM
Hello David,

The post you read is an old one. Currently there is feature which enables you to create the new records at the bottom.

You can enable the option like this:
.Editable(e => e.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom))

Of course you do not need such custom Toolbar commands anymore - the regular create button is all you need.
.ToolBar(t =>t.Create())


Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
David
Top achievements
Rank 1
answered on 30 Jan 2013, 01:07 PM
Thanks Petur.  That fixes my problem.

I still have to keep the custom toolbar button because I'm performing some custom logic on insert into the grid.  However, using the setting you provided in the Editable() method of the kendo grid fixes the issue, even when calling the javascript api (grid.addRow() in this case).

Thanks
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
David
Top achievements
Rank 1
Share this question
or