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

Row should not leave update mode if an error occurs.

6 Answers 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian Vallelunga
Top achievements
Rank 1
Brian Vallelunga asked on 22 Mar 2012, 07:15 PM
Using the new release, I enabled inline editing mode. Everything works well except that the row should remain in editing mode if there's an error performing an update to the server. Right now it just changes back to view mode. There should really be some method of displaying server-side errors in this scenario, but I'd be happy to just have it not switch out of editing mode, which gives the wrong impression that the update succeeded.

6 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 23 Mar 2012, 05:17 PM
Hi Brian,

Unfortunately such functionality is not supported out of the box. As a workaround I suggest to use the error event of the dataSource to detect the errors and the editRow method to put the corresponding row back into editing mode.

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
Brian Vallelunga
Top achievements
Rank 1
answered on 28 Mar 2012, 01:21 AM
This workaround will work, but what's the best way to get the current grid row so that I can enable editing? I'm still having trouble understanding why the current behavior is in place to begin with. It really seems like a design flaw. It doesn't even seem to cancel the changes in the underlying data source.
0
Alexander Valchev
Telerik team
answered on 28 Mar 2012, 03:59 PM
Hello Brian,

The easiest way to save the currently edited row in an inline editing mode is at the edit event - for example:
var editedCell;
 
edit: function(e) {
    editedCell = e.container;
}

I hope this information helps.

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
Brian Vallelunga
Top achievements
Rank 1
answered on 28 Mar 2012, 07:54 PM
Thanks for the help, but this method doesn't directly work. It seems that the editedRow that's being stored is already in an edit mode, and thus when I call grid.editRow(storedEditRow) nothing happens. The console just logs "undefined." What I seem to be able to do though is to store the UID of the current row and then use that to find the row in the grid for editing.
0
Alexander Valchev
Telerik team
answered on 29 Mar 2012, 02:14 PM
Hi Brian,

You are right - the row could be selected through the uid data attribute. I am sorry that I forgot to mention that in my previous reply.

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
Vivi
Top achievements
Rank 1
answered on 19 Oct 2012, 09:26 AM
Hello Brian,
                      Check the below code snippet to achieve this....
var editedRow = "";

function onError (e) {
    if (e.errors) {
        var tr = $("#Grid").data("kendoGrid").select();
        var rowItems = $('#Grid').data("kendoGrid").dataItem(tr);
        editedRow = rowItems.uid;  
    }
}

function onDataBound (e) {
    var data = $("#Grid").data("kendoGrid").dataSource.data();
    $.each(data, function (i, row) {
        if (editedRow == row.uid) {
            $('tr[data-uid="' + row.uid + '"]').addClass("k-alt k-state-selected");
        }
   });
    var grid = $("#Grid").data("kendoGrid");
    var tr = $("#Grid").data("kendoGrid").select();
    if (tr.length > 0)
        grid.editRow(tr);
    editedRow = "";
}
Tags
Grid
Asked by
Brian Vallelunga
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Brian Vallelunga
Top achievements
Rank 1
Vivi
Top achievements
Rank 1
Share this question
or