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

[Solved] EditorTemplate Model is always empty

2 Answers 415 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
jfkrueger
Top achievements
Rank 1
jfkrueger asked on 13 Jun 2012, 10:01 PM
I am using an editor template to edit an object from a grid (popup). The @Html.LabelFor and @Html.EditorFor work just fine, but the actual model is always empty and I need to use properties in the model to decide what to display. Why is the model empty and how should I be going about this?
Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 18 Jun 2012, 12:50 PM
Hello Joe,

The Model will be "empty" if you are using Ajax binding. The data will be loaded via an Ajax request on the client and is not available on the server. This is why the Grid passes an object with the default values and serializes the editor template so that it can be used after loading the data.
In order to achieve this when using Ajax binding, you should include both editors and use the Grid OnEdit event to remove the one that is not needed based on the values.

All the best,
Daniel
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
jfkrueger
Top achievements
Rank 1
answered on 21 Jun 2012, 09:20 PM
Ahh that somewhat makes sense. :-)

Thank you!
Tags
Grid
Asked by
jfkrueger
Top achievements
Rank 1
Answers by
Daniel
Telerik team
jfkrueger
Top achievements
Rank 1
Share this question
or