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

Kendo UI Grid - Position of new row

4 Answers 494 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christopher
Top achievements
Rank 1
Christopher asked on 21 Aug 2012, 07:13 AM
Hi,

Is there a way to ensure that new rows always get added to the same position in the grid (either the top or bottom)?

At the moment, we are finding that if the grid has not been sorted a new row is always added to the top. But once the grid has been sorted, the new row seems to be added to a random position

Thanks

Chris

4 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 24 Aug 2012, 09:18 AM
Hi Christopher,

Could you please specify what do you mean by "at a random position"? When the grid is sorted, new records should be inserted at a position determined by the sort criteria. The behaviour can be observed in this Fiddle:

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Christopher
Top achievements
Rank 1
answered on 27 Aug 2012, 01:25 AM
Thanks for your reply

The fiddle is a little different to our setup. We don't have a popup on editing and we have alot more rows/columns

When the grid isn't sorted the new row is always added to the top. We would like this to also be the case when the grid is sorted

So the newly added rows aren't sorted, and sit at the top until the user explicitly sorts again. Is there a way to configure the grid to work this way?

Thanks
0
Iliana Dyankova
Telerik team
answered on 29 Aug 2012, 04:37 PM
Hello Christopher,

I am afraid what you are trying to achieve is not supported on a client side. In order to get it working you need to enable server operations and implement server logic. 
 
Kind regards,
Iliana Nikolova
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Volodymyr
Top achievements
Rank 1
answered on 15 Sep 2012, 09:42 AM
I'm not sure will it help you or not but anyway...

I have a situation when I need some records to be always at the bottom not relative to the grid sorting (summary records).
So I have added the next code into the grid dataBound event.

// Move special summary row into the bottom
var rows = [];
var parent = $("table.k-focusable tbody");
$(grid.dataSource.view()).each(function (i, val) {
    var alwaysBottom = val.get("AlwaysBottom");
    if (alwaysBottom) {
        rows.push(i);
    }
});
 
$.each(rows, function (i, val) {
    $(parent.children()[val]).appendTo(parent);
});

I'm going through the dataSource collection, find records with AlwaysBottom flag (in your case them could be new records) and then just move them into the bottom of the grid (in your case could be to the top).

I hope this idea will help you.

Vova

PS. It is javascript! You can do almost everything here :)
Tags
Grid
Asked by
Christopher
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Christopher
Top achievements
Rank 1
Iliana Dyankova
Telerik team
Volodymyr
Top achievements
Rank 1
Share this question
or