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

Edit Cell with Changes in ViewModel

2 Answers 156 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 12 Jun 2012, 06:26 AM
Hi,

I have a RadGridView that has several columns with readonly set to false (ie. these can be edited). Predictably, when I edit a particular cell, the changes are changed in the relevant row in my Collection in my viewmodel when the user presses enter or clicks somewhere else.

When a change is made, I update my database.There is one or two checks I make and then the database update call itself could throw an exception so I also have a catch that reverts the values back to the original values (using e.OldValues).

Currently, similar to the example provided by Veselin in this thread, I use the RowEditEnded event handler. However, I would like to have all this logic in my ViewModel. What are my options? Do I have any? Ofcourse examples are a big help.

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 12 Jun 2012, 07:12 AM
Hello Peter,

You can try implementing IEditableObject in your business object (check out this blog post for a possible way to go).  Another possible approach would be to follow the idea illustrated in this article.

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Peter
Top achievements
Rank 1
answered on 12 Jun 2012, 11:55 PM
Thanks Maya
Tags
GridView
Asked by
Peter
Top achievements
Rank 1
Answers by
Maya
Telerik team
Peter
Top achievements
Rank 1
Share this question
or