Hi,
From this Model :
publicclassMyRowData
{
public int Id { get; set; }
public SelectList Values { get; set; }
public string Value { get; set; }
}
publicclassMyGridData
{
public IEnumerable<MyRowData> Rows { get; set; }
}
I want to bind my model to a grid in view like :
@(Html.Kendo.Grid(Model.Rows)
.Name("myGrid")
.Columns(c =>
{
c.Bound(i => i.Id).Visible(false);
c.ForeignKey(t => t.Value, t => t.Values); //Here is the bind for drop downlist (différent for each row
//And how can achieve this ?
})
.Navigatable()
.Scrollable()))
Thanks for help
Hi FranckSix,
Thank you for the code snippets and details provided.
In order to use a Foreign Key column, I would recommend using the approach from the following demo:
The following article describes how a Foreign Key column should be added for a Telerik UI Grid:
I hope this information helps.
Kind Regards,
Anton Mironov
Thank you for response.
If I understand there is no aletrnative than passing by controller to get values.
Because I have already values in my model but not on the main Model the values is on the Elements list.
I hoped to get an alternative to Controller method. Like a JQuery method to get values from model. Or a Template to create manually the DropDownList.
Hi FranckSix,
Thank you for the additional details provided.
Yes, you can use a template. These templates are called EditorTemplates.
We have default EditorTemplates files placed in the "~Views/Shared/EditorTemplates" folder of every Telerik project.
Feel free to add your custom file there.
In order to point to a field which file to use, just add a UI Hint annotation in the Model. Here is an example:
public class Order { public int OrderID { get; set; } public string ShipCountry { get; set; } [UIHint("EmployeeEditor")] public Employee Employee { get; set; } }
The following article describes the use of the EditorTemplates in more detail:
I hope this information helps. Let me know if further information or assistance is needed.
Best Regards,
Anton Mironov