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

[Solved] ASP.NET MVC Telerik grid onSave event issue

1 Answer 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Prashant
Top achievements
Rank 1
Prashant asked on 04 Sep 2012, 10:21 AM
Hi team,

I am developing an application with a simple table with <tr> and <td> layout and on the bottom of the page, I have an asp.net mvc telerik grid using .Editable(mode => mode.Mode(GridEditMode.InCell)) and have a requirement where i want whenever i change a specific gridcell value(say for example: value changes from 34 to 45), the same should get reflected in one of the related column on the top html table immediately.

I know of onSave() method of the telerik grid which saves values when the active grid cell loses focus, but i want to know how can we reflect this change of value and update the same on a specific column on html table.

Please feel free to fire any questions if you have any.

Thanks,
Prashant

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 10 Sep 2012, 06:32 AM
Hello Prashant,

If the HTML table has the same structure as the Grid table you could locate the corresponding table cell by index e.g.

function onSave(e) {
    var $cell = $(e.cell);
    var cellIndex = $cell.index();
    var rowIndex = $cell.closest("tr").index();
    var value = e.values[$cell.find("input").attr("name")];
    $("#myTable tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").html(value);
}
If the structure is different, I can suggest to add the data key as attribute(class, id) to the table row and the property name as attribute to the corresponding cell in the row.  You could then use the event argument dataItem and values to find the cell and reflect the changes.

Regards,
Daniel
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
Tags
Grid
Asked by
Prashant
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or