Differences between Create and Update actions

2 Answers 253 Views
Grid
David
Top achievements
Rank 1
Iron
Veteran
Iron
David asked on 23 Jun 2023, 03:33 PM

I have a MVC Core project which has a Grid.  It is a hierarchal grid with a child grid.  Combined they show your basic orders and history of orders.  The grid fully populates and pages.  My problems lie with the editing side of things.

I am using a pop up editor.  A editor template is used and effectively gathers users edits.  The update side of things works flawlessly.  By this I mean you click Edit, the edit occurs, you press the save and the database gets updated.  The update method receives the "model" values entered during the edit action.  This is "as expected".

My problem exists with the Create action.  Both the Update and Create use the same editor.  Visually the Create editor accepts user input however when the "Create" action is called, the server method receives a model with null values for all the values entered.  Not a single entered value is returned in the model.  No errors are present in the developer console., non are occurring in any code I have control over.  I simply cannot explain the lack of values in the model.

I have compared the "Request.Form" values in the Update vs Create methods.  My Update methods request has FORM values in approximately 107 keyvalue pairs.  When the Create methods are used it gets 47 items.  Those 47 are all the default values of the model.  (I added default values to the datasource model to test this.  Those values arrive in the model, not the entered values)

Can anyone point me to the differences between the Update/Create actions?  Can anyone point me to a path to find/solve my problem?

Thanks for any suggestions.

 

2 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 25 Jun 2023, 06:04 PM

While I still do not precisely what was wrong, I can report that I have fixed this problem.  I completely rewrote, and simplified, what the input form.

 

I think the root problem was related to the existence of a Hidden field.  I potentially had a duplicate named field in scope when and only when a new record was being created.  Upon re-creation of the process, to not use those fields, the model was successfully being returned to both the Update and Create events.  While I am not confident of my solution, it does  meet me immediate needs.

 

0
Alexander
Telerik team
answered on 28 Jun 2023, 08:55 AM

Hi David,

I would initially like to start by saying a big thank you for providing such comprehensive details in regard to the experienced issue that was held on your premises. I really appreciate it.

Generally, both the "Edit" and "Add" operations will use the same PopUp markup declaration that is specified within the Editor Template. Meaning, that the sole difference can be observed in the distinction of the endpoints which are fired depending on the operation.

In terms of differences, both of the Edit and Add backend implementation is identical with the main objective for the Create operation being to update the "Id" field as well. As it plays an integral in defying whether the model is newly created or not.

You can further see the recommended CRUD setup for the backend implementation when it comes to PopUp editing that is identical to how it is depicted in the following article:

Indeed, I agree that the described behavior is rather unorthodox. However, based on the provided alone it would be hard to pinpoint the potential culprit for the behavior with full accuracy. Nonetheless, if there are duplicate name fields in scope, then indeed model binding disruption may occur during the binding process of the Grid. For the create operation in particular.

Nonetheless, I am very happy that you have shared your solution with the community and what it should be cautious of when embarking on a scenario identical to yours. If you believe that the issue might stem from elsewhere, would it be possible for you to share the currently utilized Grid Hierarchy configuration, as well as the utilized PopUp editor on your side?

Kind Regards,
Alexander
Progress Telerik

As of R2 2023, the default icon type will be SVG instead of Font. See this blogpost for more information.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
David
Top achievements
Rank 1
Iron
Veteran
Iron
Alexander
Telerik team
Share this question
or