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

[Solved] custom edit template and viewbag

2 Answers 132 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.
Alexander
Top achievements
Rank 1
Alexander asked on 16 Jun 2011, 09:03 PM
Hello,

I am still evaluating the MVC controls and stuck at the following:
I want to create a custom edit template and show it in the standard action on edit in the Popup editor. How can I pass additional objects in the Viewbag for this edit template?

Thanks,
Alex

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 17 Jun 2011, 07:28 AM
Hello Alexander,

 It depends on the way you are binding the grid. For server binding it should be easy and straigthforward - the editor template is just a partial view. For ajax binding though things will be tricky as the editor template is instantiated client-side. In that case you need to serialize those values in JavaScript and use them in the editor. Here is a quick example:

VIEW:

<script>
     var valueFromViewBag = <%= ViewBag.SomeValue %>;
     
     function Grid_onEdit(e) {
           // use the valueFromViewBag to populate the editor template
           $(e.form).find(something).val(valueFromViewBag);
     }
</script>

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alexander
Top achievements
Rank 1
answered on 20 Jun 2011, 08:16 PM
I am using Ajax binding normally. Thanks for the example.

Alex
Tags
Grid
Asked by
Alexander
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Alexander
Top achievements
Rank 1
Share this question
or