Hi,
Is there any alternative of using AdditionalViewData if I need to include some data to my editortemplate?
The AdditionalViewData option is better than nothing but there should be a "better" way instead of using ViewData.
If there isn't anyway today, here is two options:
1. Create a similar method to AdditionalViewData and use it like:
In this way I can add some data to my editortemplates viewmodel from the current model of the view.
2. Fire a "Create" ActionResult
In a way like a normal MVC flow, when clicking "Add new item"-button, the page reloads and fires an action method like "Create" instead of the current one "Index". And in this method I can add the data I need.
I can't figure out how no 2 would work but maybe you can come up with a smart solution. Or at least no 1 would be possible I think. :)
Regards,
Mattias
Is there any alternative of using AdditionalViewData if I need to include some data to my editortemplate?
The AdditionalViewData option is better than nothing but there should be a "better" way instead of using ViewData.
If there isn't anyway today, here is two options:
1. Create a similar method to AdditionalViewData and use it like:
.Editable(editing => editing.AdditionalData(m => m.MyData = Model.MyData })
2. Fire a "Create" ActionResult
In a way like a normal MVC flow, when clicking "Add new item"-button, the page reloads and fires an action method like "Create" instead of the current one "Index". And in this method I can add the data I need.
public ActionResult Index(GridCommand command)
{
var model = ...
return View(model);
}
public ActionResult Create(GridCommand command)
{
var model = ...
model.MyData = ...
return View("Index", model);
}
Regards,
Mattias