or
columns: [
{ field: "Choices", title: "My Choices", width: "150px",
editor: function(container, options) {
$('<
input
data-text-field
=
"Name"
data-value-field
=
"Value"
data-bind
=
"value:' + options.field + '"
/>').appendTo(container).kendoDropDownList({
dataSource: {
data: myChoicesArray
},
dataValueField: "Value",
dataTextField: "Name",
autobind: true
});
}
},
{ command: ["edit", "destroy"], title: " ", width: "210px" }
],
data-value-field
=
"Value"
, I get the value (incorrectly) appearing in the grid and the viewModel correctly gets the value. On the otherhand, if I set data-value-field
=
"Name"
, I get the text correctly appearing in the grid but then the viewModel incorrectly gets the text too. I would like to have the text of the DropDownList choice appear in grid and the value of the choice stored in the viewModel. How can I do this?<%
= Html.Telerik().TreeView()
.Name("TreeView")
.BindTo(Model, mappings =>
{
mappings.For<Employees>(binding => binding
.ItemDataBound((item, emp) =>
{
item.Text = emp.EmpName;
}));
})
%>
<
div
id
=
"example"
class
=
"k-content"
>
<
table
id
=
"grid"
style
=
"float: left; position: relative"
>
<
thead
>
<
tr
>
<
th
width
=
"310px"
data-field
=
"FileName"
>File Name
</
th
>
<
th
width
=
"290px"
data-field
=
"ID"
>File Identifier
</
th
>
</
tr
>
</
thead
>
<
tbody
>
@foreach (var item in Model)
{
<
tr
>
<
td
class
=
"idRank"
>
@item.FileName
</
td
>
<
td
class
=
"idRank2"
>
@item.ID
</
td
>
</
tr
>
}
</
tbody
>
$(document).ready(
function
() {
LocationGridDataSource =
new
kendo.data.DataSource({ type:
"json"
...);
LocationGrid = ...
}
@using (Ajax.BeginForm("Bind", "Test", null, new AjaxOptions { OnSuccess = "BindOnSuccess" }, new { id = "BindForm" }))
{}
function
BindOnSuccess(context){
....
var
location = LocationGridDataSource.get(context.id);
var
selection = LocationGrid.table.find(
'tr[data-uid="'
+ location.uid +
'"]'
);
....
}