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

[Solved] Force Reload Editor Template

1 Answer 219 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.
Marco Teodoro
Top achievements
Rank 1
Marco Teodoro asked on 30 Apr 2010, 01:39 PM
Hello, i'm currently using the mvc grid whit an editor template to show a drop down list in one of the grid columns when the user is editing a row.

the drop down list will show the possible option that user can chose. But this is a table whit to primary keys, one key is always the same to each grid row but the other one will be selected by user in the drop down.

Let me exemplify : 

imagine this drop down for editor template:

<%= Html.Dropdown(null, ServiceLocator.Current.GetInstance<ICars>().GetAvailableCars((int)Session["IdGarage"]) 
            .Select(unidade => new SelectListItem  
            { 
                Text = car.name, 
                Selected = car.name.Equals(Model), 
                Value = car.name, 
            }))%> 

this will create the following html 
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>


Now imagine that user will chose Volvo. so in the next row the list of options should not have the volvo option.

But as editor template are loaded only on the load of the Grid the options will be the same.

If i make a refresh the editor template is reloaded and the options retrieved are already filtered.

how can i reload the editor template without reload the entire view?

can i use a strait forward JavaScript code to reload the editor template? 
or i need to make a JavaScript post to controller to bring the json object and create the html on my way?

hope someone have a better approach to achieve this behavior, because i really want to maintain the ajax functionalities but i don't want to "pollute" my view whit JavaScript that i can't test.

Best Regards
Marco

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 30 Apr 2010, 02:12 PM
Hi Marco Teodoro,

The only option is to implement the population of the <select> with JavaScript. As you suggested the editor template is output initially when the grid is rendered for the first time. After that only the value of the input control is updated when editing. To modify this behavior you can use JavaScript in the edit template ascx and hide/add the values of interest.

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.
Tags
Grid
Asked by
Marco Teodoro
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or