I have an editable grid with custom EditorTemplate, the grid has "InLine" edit mode.
I would like to send a property to this EditorTemplate by using EditorViewData. This property is assigned to the selected row.
@(Html.Kendo().Grid<VehicleWithTrackerDTO>()
.Name(
"VehiclesGrid"
)
.Events(e => e
.ExcelExport(
"excelExport"
)
.BeforeEdit(
"getColor"
))
.Columns(columns =>
{
// LOOK AT THE FIRST LINE BELOW:
columns.Bound(d => d.ImageId).Title(
"Image"
).ClientTemplate(
"<img src='"
+ Url.Content(
"~/imgs/"
) +
"#:Image#'/>"
).Width(120).Sortable(
false
).Filterable(
false
).EditorViewData(
new
{ colorId = 1 });
// colorId = 1 should be replaced with something like #:ColorId#
columns.Bound(d => d.Brand).Width(200).Filterable(fb => fb.Multi(
true
).Search(
true
));
columns.Command(command => { command.Edit(); }).Width(100);
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(source => source
.Ajax()
.Events(events => events.Error(
"errorHandler"
))
.Model(model => model.Id(p => p.DeviceId))
.Read(read =>
{
read.Action(
"GetVehicles"
,
"Vehicles"
).Data(
"searchQuery"
);
})
.Update(update => update.Action(
"Update"
,
"Vehicles"
))
)
)
My question is how can I send an item with "" property?
My first idea was to create a javascript function, which will return data like this:
function
getColor(e) {
return
{
colorId: e.model[
"ColorId"
]
};
}
But I can't see the solution to pass this data into EditorViewData method.
Thanks,
Mateusz