1

I have DevExpress MVC GridView which is bound to Model (List < Employee >), but I don't have all class properties added as table columns. When UpdateRowRouteValues is called, I'll get new Employee instance in controller method parameter, but not all properties are set (those which are not in columns collection). Is there any way how to get this instance with all properties set (all old values set + modified)?

Example: class Employee -FirstName, LastName, Age, IsActive

Columns: -LastName, Age

Then in controller I want to have FirstName and IsActive old/unchanged values and new LastName and Age values, but in parameter are FirstName null and IsActive false.

In addition I don't want to add all properties as columns and set Visible=false, because you can still see them in Column Chooser.

I was thinking about creating new extra class with LastName,Age properties only and then merge these two instances, but not sure if it's the best solution for large project where columns could be changed often (maintain two classes for one table and merge function).

Domestos99
  • 88
  • 6
  • If you do not send the information in the request, then your controller cannot 'guess' what they are. You use a view model, then get the data model from the database (based on its ID) and update its properties from the view model then save the data model –  Sep 03 '17 at 00:28

1 Answers1

0

You can either restore the initial (hidden) values from a Model by a key

or

use the approach from the GridView - How to implement data editing with hidden column example (i.e., save the edited row's hidden values via custom JSProperties and pass them back to a controller on update).

Mikhail
  • 9,186
  • 4
  • 33
  • 49