I am creating a Dynamic Kendo Grid using GridBoundColumnBuilder().
I loop through all of the controls on the previous page to create the grid. For example with myTextbox(), myCheckbox(), etc.
These create columns in the grid. I have all of the columns creating and populating with data.
My issue is with the Dropdownlist and the Multiselect list, they populate with data but do not display the correct data when the grid is created. The dropdown list displays the value, not the text of the previous control:
1 = My
2 = Data
The Dropdownlist will display 1 instead of My. And, the Multiselect only displays [object Object].
When you click on either of the controls in the grid it switches to show the proper text, but loses it when you click off.
Any ideas of what I am doing wrong?
foreach
(ControlBase control
in
flatColumns)
{
GridBoundColumnBuilder<dynamic> thisColumn;
if
(control.Lookups !=
null
&& control.Lookups.Any())
{
if
(!control.IsMultiSelect){
thisColumn = column.Bound(control.ControlType, control.ColumnName).Title(control.Description);
thisColumn.EditorTemplateName(
"DropDownList"
);
thisColumn.Width(250);
}
else
{
thisColumn = column.Bound(control.ControlType, control.ColumnName).Title(control.Description);
thisColumn.EditorTemplateName(
"MultiDropDownList"
);
thisColumn.Width(250);
}
}
}
Dropdown Template
@(Html.Kendo().DropDownListFor(m => m).HtmlAttributes(
new
{ @
class
=
"form-control"
})
.BindTo((IEnumerable) ViewData[currentColumn +
"List"
])
.DataTextField(
"Text"
)
.DataValueField(
"Value"
)
.ValuePrimitive(
true
)
Multiselect Template
@(Html.Kendo().MultiSelectFor(m => m)
.HtmlAttributes(
new
{ @
class
=
"form-control"
})
.BindTo((IEnumerable)ViewData[currentColumn +
"List"
])
.DataTextField(
"Text"
)
.DataValueField(
"Value"
)