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

rowclick toggles edit mode with update

1 Answer 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nancy
Top achievements
Rank 1
Nancy asked on 18 Oct 2013, 07:31 PM
I have a rowclick event that puts the row into edit mode:

function RowClick(sender, eventArgs) {
sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
}

Now I want to modify it so that clicking the row a second time takes it out of edit mode and saves it - just as though you were clicking 'update'.

I also need to remove the update/cancel so that only clicking on the row toggles edit/update mode

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 23 Oct 2013, 03:37 PM
Hello Nancy,

The approach you describe could be achieved with some JavaScript code. You could use theRadGrid's OnRowClick event handler and check if the clicked row is in edit mode. If this condition is met the updateItem() method should be called and the changes would be submitted to the data source. The handler would look similar to this:

function RowClick(sender, eventArgs) {
    var masterTable = sender.get_masterTableView();
    var itemIsInEditMode = eventArgs.get_gridDataItem().get_isInEditMode();
 
    if (itemIsInEditMode) {
        masterTable.updateItem(masterTable.get_dataItems()[0].get_element());
    }
    else {
        masterTable.editItem(eventArgs.get_itemIndexHierarchical());
    }
}

The "Update" and "Cancel" buttons are not displayed when AutoGenerateEditColumn property for the RadGrid is set to false and the is no edit column defined.

I am attaching a runnable project illustrating the described approach.

Let me know if this is helpful to you.

Regards,
Viktor Tachev
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Nancy
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or