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

Re-sort grid after local data item has been added

7 Answers 402 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 15 Apr 2014, 11:26 AM
I've attached event listeners to every data source and grid event but none seem to allow me to refresh the grid without harming the newly added data or next-added data. DataSource's change event when only e.actions == "itemchange" seemed the closest but I'd have to add a setTimeout. I had problems with the grid's edit and save events (both called too soon). I was using grid.refresh(). Another approach is appreciated

7 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 17 Apr 2014, 07:48 AM
Hello Rayn,

Basically to re-sort the Grid after you have created a record you can use the requestEnd event of the DataSource to perform read();

e.g.

requestEnd: function(e) {
  if(e.type != "read") {    
    this.read();
  }
},

Let us know if I missed something. Feel free to demonstrate what you experience in a Dojo example.

Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ryan
Top achievements
Rank 1
answered on 17 Apr 2014, 07:01 PM
Hi Petur,

Thanks but I am having trouble with this. I'm using a local datasource. When I add a row it doesn't call requestEnd by default. I tried to use .saveChanges() on the grid save event it wipes out my added record. 

See my dojo example here - http://trykendoui.telerik.com/IFed/3

Note that after adding a record and then manually sorting my added row is removed. Help appreciated!
0
Petur Subev
Telerik team
answered on 21 Apr 2014, 12:34 PM
Hello Rayn,

There are many things that need to be handled, basically to make sure that everything is working properly and the array is updated and all the events are also triggered you should declare the transport operations as functions. Thus you can still save all the changes on the client side and achieve your goal with calling sync and applying sorting after saving.

Here is what I made out of your snippet:

http://trykendoui.telerik.com/@pesho/alAk

I hope it helps.

Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ryan
Top achievements
Rank 1
answered on 28 Apr 2014, 07:34 PM
Hi Petur,

I'm still having problems with this. I've updated my example with some of your advice.  http://trykendoui.telerik.com/IFed/7

To reproduce the problem:
  1. Add a row
  2. Enter data and hit enter
  3. Sort the first column a few times
  4. Repeat steps 1-2
  5. Save event is not fired

I've also created a screencast demonstrating the problem described above. http://screencast.com/t/oqI8qQO1e

0
Petur Subev
Telerik team
answered on 30 Apr 2014, 12:55 PM
Hello Ryan,

Thank you for providing the updated example. Basically this is happening because there is a small issue with the navigatable of the Grid. When you first sort the Grid and then you add new record fill the fields and press enter - the Grid actually performs a sort, like you are pressing the sorting header again.

As a small work-around before we fix this internally I can suggest you to use the edit event of the Grid to update its private field used for navigation. Like this:

edit: function (e) {
  debugger;
     this._current = e.container;
    log('grid: edit');

Here is a small example.

http://kendobuild.telerik.com/dojo-staging/@qr3ca/iRum

I hope this helps.

Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ryan
Top achievements
Rank 1
answered on 30 Apr 2014, 01:02 PM
Okay, thanks. I can't access that example but I understand the premise. Based on your explanation, I expected disabling navigatable to also resolve the issue. It very well might but I noticed that disabling navigatable no longer allows saving a row via the enter key. Is saving a row via enter the intended result or an unintended side effect of navigatable?
0
Petur Subev
Telerik team
answered on 01 May 2014, 08:20 AM
Hello Ryan,

Indeed the navigatable support enables you to create/update a row when the enter key is pressed. Here is a jsbin version that work-arounds the issue the way I shared.

http://jsbin.com/fujow/1/edit

I informed the team about this and soon it should be fixed internally.

I am sorry for the inconvenience caused.

Kind Regards,
Petur Subev
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
Ryan
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Ryan
Top achievements
Rank 1
Share this question
or