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

[Solved] Popup Editor Template With Dropdown Based on Main Model

3 Answers 83 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.
Victor
Top achievements
Rank 1
Victor asked on 31 May 2011, 04:02 PM
Hi!

We have a Grid component listing Employees of a specific type (say developers) in a company, where the company is selected by the user (website.com/ListDevelopers/{GuidOfCompany}). The model for that page is similair to this:
public class CompanyViewModel {
  public Guid Id {get;set;}
  public String Name {get;set;}
  public List<EmployeeViewModel> {get;set;}
}

We use a popup for insert and edit, using an editor template.

In the "Add" popup, we want the user to be able to select an Employee of the current company using a DropDown and then set some other properties. That is, we want to pass the CompanyViewModel Id to the Editor Template. How do we do that?

Kind regards
Victor Ström

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 03 Jun 2011, 03:59 PM
Hello Victor,

 
Depending on the given information I understand that the grid is bound to List<EmployeeViewModel> and the edit and insert is accomplished with custom edit template. If this is the case the grid will pass edited EmployeeViewModel to the edit form. Grid does not have idea for the CompanyViewModel.Id. That is why you will need to persist it somewhere and retrieve it when you need it (in the edit template). If the grid is bound server-side then you can use TempData. On the client-side you can get id from the URL using javascript.

Regards,
Georgi Krustev
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
Victor
Top achievements
Rank 1
answered on 07 Jun 2011, 08:26 AM
Hi!

Thanks for those pointers, we will either add the desired Id to the template or go with the approaches you mentioned. Thanks again.

/Victor
0
Victor
Top achievements
Rank 1
answered on 07 Jun 2011, 01:16 PM
Hi again,

Since the popup editor content is generated server-side no matter what, we ended up going the TempData route for now, however it seems like a quite "bad" solution, since there is no good way to require that argument. If anybody has any better options to solve this problem (populate a dropdown based on the page the grid rendering the editor is rendered on), that would be much appreciated.

Thanks for a working solution though

/Victor
Tags
Grid
Asked by
Victor
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Victor
Top achievements
Rank 1
Share this question
or