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

UpdateCommand doesn't clear the edit controls

5 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave Hayward
Top achievements
Rank 1
Dave Hayward asked on 18 Jan 2010, 10:38 PM
There are a lot of posts on the UpdateCommand function, but I couldn't find a solution to my problem in any of them.

I'm hooking into UpdateCommand and performing my own data update functions. Using the examples and suggestions from the site I was able to get everything working beautifully, with one exception. After performing the actual update, the grid remains in what appeard to be the edit mode. (This behaves the same if I don't hook into UpdateCommand and there is no data source defined).

I looked for solutions to this, and there seem to be a couple suggested that work well if the EditMode is EditForms, but I'm using InPlace. When I try to use the solutions from the other posts, I get an exception: Only items with IsInEditMode set to true can be updated. This happens if I try to call MasterTableView.ClearEditItems() or if I try to set e.Item.Edit to false

I looked at the samples in the Help section, and none of them show any hint there's something more to be done, so I'm not sure what I'm doing wrong. Can anyone suggest a way to get back to 'normal' selection mode with no editing controls visible?

TIA.  

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 19 Jan 2010, 06:55 AM
Hello Dave,

Have you set the AllowAutomaticUpdates property of the grid to true? If so, try setting it to false and see if it helps close the edit form after update.

Also the following code should be tried in UpdateCommand, to clear the rows in editmode
cs:
 protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)  
    {  
        // update query code goes here  
  
        RadGrid1.MasterTableView.ClearEditItems(); 
    }  

Thanks
Princy.
0
Dave Hayward
Top achievements
Rank 1
answered on 19 Jan 2010, 12:22 PM
Princy,

Thanks for your prompt response. I had tried that one, as I found it in one of your earlier posts. That's the one that cased the exception. I also tried:

e.Item.Edit = false
 That too gave me the same exception.

If I use EditForms mode it works, but in InPlace EditMode, it fails.

0
Dave Hayward
Top achievements
Rank 1
answered on 19 Jan 2010, 08:50 PM
I don't know if it helps at all, but I'm experiencing this behaviour with the DropDown column type. I also have a HTMLEditor column, and it doesn't behave like this. After returning from the UpdateCommand handler, the grid returns to its nomal (non-editing) mode.

I don't know if this helps.
0
Princy
Top achievements
Rank 2
answered on 20 Jan 2010, 09:08 AM
Hi Dave,

Could you try firing the FireCommandEvent for the Cancel event in the UpdateCommand after the update query as shown below:

GridEditableItem editedItem=(GridEditableItem)e.Item;
editedItem.FireCommandEvent("Cancel""");


Do let me know if this works for your scenario.

Thanks,
Princy
0
Dave Hayward
Top achievements
Rank 1
answered on 20 Jan 2010, 12:35 PM
Princy,

Thanks! That worked. It seems like a bit of a hack though. Is UpdateCommand supposed to work like this? Should I report a bug?Maybe I just don't grasp the concepts yet.

Anyway, that works, and that's great.

Thanks again.
Tags
Grid
Asked by
Dave Hayward
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Dave Hayward
Top achievements
Rank 1
Share this question
or