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

[Solved] Turn Off Edit Mode for a Row

7 Answers 291 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Suresh Mishra
Top achievements
Rank 1
Suresh Mishra asked on 04 Feb 2010, 10:11 PM
If a row is in edit mode and user clicks on the Update link, I would like to make changes to the database in the update event of the radgrid and then make the row uneditable till he double clicks again.  How do I do this on the server side?

I found this code to do this on the front end:

$find("<%= RadGridEmpData.MasterTableView.ClientID %>").cancelAll();

, but I need to do this on the server side after updates are done.

Thanks.

Suresh

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Feb 2010, 11:26 AM
Hello Suresh,

I guess you want to disable the Edit link on updating the row and want to re-enable when doubleclicking the row. If so you can try the following code snippet in order to disable the Edit linkbutton.

CS:
 
    protected void RadGrid1_ItemUpdated(object source, GridUpdatedEventArgs e) 
    { 
        GridDataItem item = (GridDataItem)RadGrid1.MasterTableView.Items[e.Item.ItemIndex]; 
        LinkButton editLink = (LinkButton)item["AutoGeneratedEditColumn"].Controls[0]; 
        ScriptManager.RegisterStartupScript(thisthis.GetType(), "key""disableLink('" + editLink.ClientID+ "');"true); 
    } 

Here is the code for attaching ondoubleclick event for the row.
CS:
 
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            LinkButton editLink = (LinkButton) item["AutoGeneratedEditColumn"].Controls[0]; 
            item.Attributes.Add("ondblclick""check('"+editLink.ClientID+"','"+item.ItemIndex+"');"); 
        } 
    } 

The client events used:
 
    <script type="text/javascript"
        function disableLink(id) { 
            document.getElementById(id).disabled = true
        } 
        function check(id, index) { 
            document.getElementById(id).disabled = false
        } 
    </script> 

Modify the code according to your need.
Shinu.
0
Suresh Mishra
Top achievements
Rank 1
answered on 08 Feb 2010, 08:46 PM
Hi Shinu,

Thank you very much for your prompt response.

Actually, the intent here is to return the row in the edit mode as shown in the attached screen shot.  After the update event is processed and the database is updated, I would like to make the first row look like the second one.  I have a feeling that this can be done with the Scriptmanager that you indicated, but I am not sure how.

Your help will be greatly appreciated.

Regards.

Suresh
0
Martin
Telerik team
answered on 11 Feb 2010, 06:49 PM
Hi Suresh Mishra,

I am not sure that I completely understand your scenario. In your initial post I have noticed this sentence:

"I would like to make changes to the database in the update event of the radgrid and then make the row uneditable till he double clicks again"

However in your last post you say:

"Actually, the intent here is to return the row in the edit mode as shown in the attached screen shot."

Could you provide some more details about what exactly you intend to do. You can also open a formal support ticket and send us a small sample project demonstrating you scenario.

Regards,
Martin
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Suresh Mishra
Top achievements
Rank 1
answered on 15 Feb 2010, 08:36 PM
Martin,

Sorry to have caused some confusion.  Let me reword the situation. 

Here is what I am trying to do:  A row is displayed as in file named, 1-StartingState.jpg.  The row is placed in the Update state by clicking on the Edit link.  The user then makes changes to the row and clicks on "Update" to update the row.  After this happens, the rows stays in "Update" state as in "2-UpdateState.jpg".  Instead of letting the row remain in "2-UpdateState.jpg", I would like to show the row as in the third file, "3-DesiredStateAfterUpdate.JPG", i.e. close the row for updates.

Please do let me know how to achieve this.

Thanks!

Suresh
0
Princy
Top achievements
Rank 2
answered on 16 Feb 2010, 06:34 AM
Hi,

You can clear the EditIndexes collection in the UpdateCommand after performing the Update operation as shown below:

  RadGrid1.EditIndexes.Clear(); 
  RadGrid1.Rebind(); 

This will close the edit form after the update .

Hope this helps.

Thanks,
Princy
0
Suresh Mishra
Top achievements
Rank 1
answered on 16 Feb 2010, 01:50 PM
Princy,

This worked very well.  Thank you, very much.

Suresh
0
Suresh Mishra
Top achievements
Rank 1
answered on 25 Feb 2010, 03:10 PM
Hi Princy,

Your code worked very well when I use it within the Update event of the radgrid.  However, when I run that script from outside of the "Update" event of the radgrid, the code does not work - a line remains in edit mode. 

Your help will be greatly appreciated because this is holding our release to produciton.

Thanks!

Suresh
Tags
Grid
Asked by
Suresh Mishra
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Suresh Mishra
Top achievements
Rank 1
Martin
Telerik team
Princy
Top achievements
Rank 2
Share this question
or