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

I need an example of saving MVVM model with view controller

1 Answer 94 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Nathan
Top achievements
Rank 1
Nathan asked on 24 Sep 2012, 09:30 PM
I am fairly new to MVC
I have tried all day to use the MVVM Remote Binding example to update the model using form post instead of json to post to a controller action and it won't map the post data to the IEnumerable<ProductViewModel> products argument of my controller action. I have inspected the post parameters and this is what I see:

models[0][Discontinued] false
models[0][ProductID] 3
models[0][ProductName] Aniseed Syrup
models[0][UnitPrice] 12
models[0][UnitsInStock] 13
models[0][UnitsOnOrder] 0

In the working example for Kendo Grid Editing Custom, I noticed that the post parameters should be more like this:

models[0].Discontinued false
models[0].ProductID 3
models[0].ProductName
Aniseed Syrup
models[0].UnitPrice 12
models[0].UnitsInStock 13
models[0].UnitsOnOrder 0

Notice how the properties are not indexed. I am guessing that this is why it doesn't work.

Does anyone have a working example (with controller source) of Kendo MVVM being used to update the model?

1 Answer, 1 is accepted

Sort by
0
Nathan
Top achievements
Rank 1
answered on 25 Sep 2012, 03:03 PM
I figured it out. After several hours of stepping through the javascript on my project and then finally on the kendoui example project with full js source code, I found that I really needed to have the kendo.aspnetmvc.min.js file included in my page. It apparently adds a parametermapping function to the datasource that doesn't exist without that script. Now everything is working fine.
Tags
MVVM
Asked by
Nathan
Top achievements
Rank 1
Answers by
Nathan
Top achievements
Rank 1
Share this question
or