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

keep the selected row highlighted after edition

3 Answers 321 Views
Grid
This is a migrated thread and some comments may be shown as answers.
martin
Top achievements
Rank 1
martin asked on 28 Nov 2012, 10:12 AM
Hi there, 

I am currently editing my grid not using the Kendo editor. I send the grid cell to my editor and refresh the grid after edition is complete. 
What I am trying to do is to keep the edited line highlighted using dataBound(). But because of the asynchronous load of data, the dataBound function is executed before my grid is fully loaded. 

Here is the used code, I really cannot figure out why the dataBound function is executed before data are loaded. 

var kendoDefaultParams = {
     // removed for clarity
    dataBound: onDataBound,
     // removed for clarity
};
 
$("#grid").kendoGrid(kendoDefaultParams);
 
function onDataBound() {
    gva.reSelectElements();
};
 
 
reSelectElements = function () {
    // gva.selectedVms() contains the previous selected elements
    if (gva.selectedVms().length == 0 || gva.selectedVms() == null || gva.selectedVms() == undefined) { return; }
    var id = gva.selectedVms()[0].uid;
    var grid = $("#grid").data("kendoGrid");
    var row = grid.table.find("tr[data-uid=\"" + id + "\"]");
    grid.select(row);
};

Am I doing something wrong ?? 

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 30 Nov 2012, 08:20 AM
Hello Martin,

I am not sure if I understand correctly how are you performing the editing and refreshing the Grid. Could you share the code you are using? The DataBound event should be triggered after the data is received and the rows are created. If you are reading the data again however, the uids will be different since new observable objects will be created. If that is the case then you should either use the model ID or the row index to restore the selection. 

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
martin
Top achievements
Rank 1
answered on 30 Nov 2012, 09:34 AM
Hi Daniel !

you are right, the reason why it did not work is that I was searching based on the uids. 
I have changed it and it does work now.

Thanks a lot !! 

I have another question though. I am using Kendo and Knockout, so I have changed the kendo.ns value to kendo. 
i.e: I have written kendo.ns = "kendo";
sorting does not work when I click on the column header but it does work when I use the column menu. Paging works but when I click on a page number, I also have an error, the same one which is
Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Do you have an idea about how I could fix it ?? I have tried with the latest jquery version (as I have read in some forums) but it did not change anything. 

edit: 
the error occurs on the line where I send the dataSource result in server-side
DataSourceResult ds = (result as IEnumerable<Object>).ToDataSourceResult(request);
and I am using the v2012.3.1114 version of Kendo
0
Daniel
Telerik team
answered on 03 Dec 2012, 08:31 PM
Hello Martin,

This is a problem that we recently discovered. The sortable implementation does not take into account the namespace so the field name is not found. We will fix this for the next internal builds and official releases. I am sorry for the inconvenience caused.

Kind regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
martin
Top achievements
Rank 1
Answers by
Daniel
Telerik team
martin
Top achievements
Rank 1
Share this question
or