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

Alternative to AdditionalViewData?

1 Answer 156 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mattias
Top achievements
Rank 1
Mattias asked on 23 Nov 2012, 04:26 PM
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:
.Editable(editing => editing.AdditionalData(m => m.MyData = Model.MyData })
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.
public ActionResult Index(GridCommand command)
{
     var model = ...
     return View(model);
}
 
public ActionResult Create(GridCommand command)
{
     var model = ...
     model.MyData = ...
     return View("Index", model);
}
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

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 28 Nov 2012, 12:11 PM
Hello Mattias,

I would suggest you to share such ideas on our Kendo User Voice page. This way if more customers support the idea we will consider improving the functionality.

http://kendo.uservoice.com/

All the best,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Mattias
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or