c# - An explanation of Kendo MVVM and MVC -


so,

i see if can sort of explanation here. developing , application in asp.net mvc , continue run situation of needing create dynamic pages number of ajax calls on page update data, reload tables, , other such tasks. don't know lot mvvm technology have done reading , tried examples on kendo mvvm. really how can bind data view model on front end , perform number of actions while manipulating client side model. mvc have update data server side , have client side changes reflected on server side model.

i have read couple articles mention these 2 different technologies aren't intended used together, feel reduce development time , complexity if somehow these technologies play nice together. possible perform data manipulations , update client side tables , data presentation mvvm , submit client side changes server via post method? having difficulty tracking down how this. if not possible or bad development practice, explanation why isn't possible?

they 2 different technologies, there's absolutely no reason not use them in conjunction each other in particular case.

think how you're using mvc currently, have models, typed , there aid in displaying data on view. let's wanted display car. include following code on view wanted display data on.

@model car 

now think how achieve using javascript...

it's simple, display data on view json, , consume javascript...

i've written simple extension method can use achieve this.. add class below project...

public static class htmlhelperextensions {     public static ihtmlstring jsonfor<tmodel>(this htmlhelper<tmodel> helper, tmodel model)     {         return jsonfor(helper, model, formatting.none);     }      public static ihtmlstring jsonfor<tmodel>(this htmlhelper<tmodel> helper, tmodel model, formatting formatting)     {         string jsonmodel = jsonconvert.serializeobject(model, new jsonserializersettings         {             referenceloophandling = referenceloophandling.ignore,             formatting = formatting         });          return new htmlstring(jsonmodel);     } } 

then in view....

@section scripts {     <script type="text/javascript">         var cardata = @(this.html.jsonfor(this.model));         function car(car)          {             var self         = this;             self.numberplate = ko.observable(car.numberplate || '');             self.name        = ko.observable(car.name        || '');             self.model       = ko.observable(car.model       || '');             self.yearmade    = ko.observable(car.yearmade    || '');             self.color       = ko.observable(car.color       || '');             self.fuel        = ko.observable(car.fuel        || '');         }     `         ko.applybindings(new car(cardata));     </script> } 

is possible perform data manipulations , update client side tables , data presentation mvvm , submit client side changes server via post method?

yes.

all need post data controller action using ajax.


Comments