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

Problem with dropdownlist in grid

1 Answer 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AspenSquare
Top achievements
Rank 1
AspenSquare asked on 30 Jul 2013, 04:02 PM
I'm trying to add an EditorTemplate to my grid and it's not selecting the correct value on edit.

Any suggestions?

1 Answer, 1 is accepted

Sort by
0
AspenSquare
Top achievements
Rank 1
answered on 31 Jul 2013, 01:09 PM
From my ticket....



Set the StateId to be the visible column, and use ClientTemplate to display the "State" field:
columns.Bound(p => p.StateId).Width(80).ClientTemplate("#=State#");
columns.Bound(p => p.State).Hidden(true);
Set the custom EditorTemplate to the "StateId" field in the model:
public class MarkupState
{
    public int PayrollMarkupId { get; set; }
    public string State { get; set; }
    [UIHint("StatesEditor")]
    public int StateId { get; set; }
    public decimal? MaintenancePercentage { get; set; }
    public decimal? OfficePercentage { get; set; }
}
Modify the EditorTemplate in the following way:
@model int?
  
  
@(Html.Kendo().DropDownListFor(m => m)
    .DataValueField("StateId")
    .DataTextField("ShortName")
    .BindTo((System.Collections.IEnumerable)ViewData["states"])
)
Tags
Grid
Asked by
AspenSquare
Top achievements
Rank 1
Answers by
AspenSquare
Top achievements
Rank 1
Share this question
or