- Home
- Forum
- ASP.NET MVC - EJ 2
- CRUD and Model Binding
CRUD and Model Binding
Hi guys,
We are just starting to have a play with the Syncfusion MVC components and I have a question about posting data back to the controller.
We have been using our own form controls for a while now, so binding data to a model and posting back to the controller has been quite easy. EditorFor's etc used and all properties are set when the form is submitted back to the controller. Using our own controls and editor templates mean we have a lot of control over the flow between the view and controller.
Now we are having a bit of play with Syncfusion, I'm struggling to find an example or doco to get the data bound properly to models when posting back.
An example of the sort of thing we would usually do:
- Model with a number of properties, some of which could be a list of objects
- View with a form with EditorFor's for the basic properties (boolean, strings, ints etc). A for loop to loop through the list items to create editors, which results in the correct name being used in the html input control and therefore the model binder will pickup the values and they will be present in the model when it is passed back to the controller. The view will have a submit/save button at the bottom of the form to submit the data back to the controller.
- Controller that has a post action that accepts the model. From here we do a DB store, or manipulate the model etc.
- How to properly create a grid from a list item that allows bulk edit and then send back the whole grid in custom model
- Is it possible to have a form with several items, including a grid, with a submit/save button and the form is submitted to the controller with all properties, including the list items from the grid, populated.
I've managed to figure this out a little more.
After looking at some posts I can see that the Added, Changed and Deleted properties are important in the model and they are what the grid uses to bind the data.
Is it possible to get every row of the grid? So an Unchanged property
- Please share the data adaptor used in your Grid application.
- Do you want to send additional data from the Grid component to the server side when you perform the CRUD operation?
- Do you want to use complex field data in your Grid application?
- Please share more details on the query “Is it possible to get every row of the grid? So an Unchanged property”.
Hi Ajith,
Thanks for the reply :)
- I had been using the RemoteSaveAdaptor adaptor.
- The plan is yes to more data. So the data in the grid would potentially only be one property of a parent model. So for example I might have a PersonModel, with a string firstname, string lastname, int age and a list of HobbieModel's for example. Hitting save on the form should submit all properties and set values to the controller, including every row of the grid that is bound to the HobbieModel, regardless of whether they have been added, deleted or updated.
- Potentially, although at the moment I am just trying to get step 2 working :)
- See point 2. Let's say the grid has 4 rows by default, set in the controller, and the user can update the data in the grid. They might update rows 1 and 3, which will be in the updated list of models, but I also want to send rows 2 and 4, even though they have not been changed. So 4 rows in, 4 rows out.
- 5 Replies
- 2 Participants
-
WG Warrick Goddard
- Nov 20, 2021 01:28 AM UTC
- Nov 29, 2021 03:35 AM UTC