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

Add new after sorting puts the new row on the last page

4 Answers 409 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Charles
Top achievements
Rank 1
Charles asked on 20 Aug 2015, 07:43 PM

We are attempting to implement grid with sorting, and we've found that when we sort, then click the add button, the new row ends up as the last row on the last page, if the sort happens to send it there because of its empty columns.  It ends up causing validation problems, but the culprit is never shown on the screen, and we're worried that will be confusing for the users.  We were wondering if this was an existing bug, or if there was some workaround to keep the newly inserted row at least somewhere in sight after it is first added.  

 

Thanks

4 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 24 Aug 2015, 03:01 PM

Hello Charles,

Actually this is expected behavior since when "Add new item" is clicked it is added to the data source and opened for editing. 

A possible workaround is to navigate to the last page when sorting is enabled. Please refer to the http://jsfiddle.net/OnaBai/sAVGk/ example. 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Curt
Top achievements
Rank 1
answered on 24 Aug 2015, 03:39 PM

[quote]Actually this is expected behavior since when "Add new item" is clicked it is added to the data source and opened for editing. 
A possible workaround is to navigate to the last page when sorting is enabled. Please refer to the http://jsfiddle.net/OnaBai/sAVGk/ example. [/quote]

'Expected behavior' is for the row to be inserted in some random location the user cannot see it?

 [quote]A possible workaround is to navigate to the last page when sorting is enabled. Please refer to the http://jsfiddle.net/OnaBai/sAVGk/ example. [/quote]

 The example you are referring to is broken. When sorted, the rows are being inserted at the top of the list, and the last row is stuck in edit mode.

0
Boyan Dimitrov
Telerik team
answered on 25 Aug 2015, 02:48 PM

Hello Curt,

 

In order to avoid any confusions I would like to clarify the following: 

 

When an item new is added, the DataSource inserts the new item at a specific position according to the sort expression. For example if the Kendo UI Grid is sorted by the ProductName in descending order, the new item by default is created with empty string ProductName value. So it is expected that the newly created item to be placed at the bottom (last page). 

 

So the newly created item is not placed at random position, but rather the sort expression is taking into account and the item is placed on the right position according to the sorting. 

 

Given this the only possible solution would be to find the item, navigate to the page and open the item for edit. 

Regarding the example in my response -the Grid should be sorted by FirstName in descending order and then add new item. Since it is only for demonstration purposes always the last child of the last page is open for edit. 

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Charles
Top achievements
Rank 1
answered on 27 Aug 2015, 01:44 PM

Right now we've got a workaround in that stores the sort, and then drops it from the datasource when we add a new row.  Then, when the datasource is saved the sort gets re-applied.  

It's not a perfect solution but it seems like the only thing that is allowed by the client side sorting.

It is a shame that new rows can't be flagged as new, and ignored by the sort until they are 'saved'.  That would allow you to see the row that you inserted all the time, rather than sometimes.  I think the end users would probably appreciate it.

Tags
Grid
Asked by
Charles
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Curt
Top achievements
Rank 1
Charles
Top achievements
Rank 1
Share this question
or