Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to implement data editing with hidden column

$
0
0

Problem:

I need to hide some columns in the GridView because they are utilized for internal purpose (e.g., rowversion column). At the same time, it is necessary to have these column values in the update action method specified via the MVCxGridViewEditingSettings.UpdateRowRouteValues Property. Currently, the corresponding values are empty.

Solution:

This issue occurs because the generated HTML does not contain INPUT fields that correspond to hidden columns. For this reason, when data is posted to the server, the corresponding model fields are left empty (the model binding mechanism cannot find appropriate values for these fields). To solve this problem, you can use the approach from the Passing Values to Controller Action Through Callbacks help section to forcibly pass the required values to the update action method. In addition to the MVCxClientGridView.BeginCallback Event, you need to handle the GridViewSettings.CustomJSProperties Event to pass the currently edited row values to the client side.

Note:

If it is OK for you to show the caption and editor of the hidden column in the Edit Form, you can use a much simpler solution. Just set the GridColumnEditFormSettings.Visible property to true. This approach might be useful when you are hiding columns via the Customization Window.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>