This question is locked. New answers and comments are not allowed.
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>
<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