I am trying to get a list of selected model records from a Kendo Grid, alterady did that with Ajax bindings, but when I try to do with local bind (BindTo) the datasource is not set in javascript and so I cannot get the data.
I am trying to make a DatePicker column into the Grid and the only way I could make it work is using local bind with template property for the column, so I cannot even set the datasource from the grid with Ajax and ServerOperation(false) since that way it would force me to use ClientTemplate instead of Template and that way the DatePicker did not work.
Someone know if there is a way to do that?
This is my Grid:
@(Html.Kendo().Grid<RR.Mvc.Models.SoumissionFinantial.FinancementViewModel>()
.Name("ListeMontagesResults")
.Height("100%")
.Columns(columns =>
{
columns.Bound(p => p.CodeMontage)
.Title(ResourcesRR.lblListeMontageCodeMontage)
.HeaderHtmlAttributes(new { style = "text-align: center; justify-content: center;" })
.HtmlAttributes(new { style = "text-align: center;" })
.Width(100);
columns.Bound(p => p.SubmitDate)
.Title(ResourcesRR.lblDate)
.Width(150)
.HeaderHtmlAttributes(new { style = "text-align: center; justify-content: center;" })
.Template(t =>
Html.Kendo().DatePicker()
.Value(t.SubmitDate)
.Name(@"SubmitDate_" + t.CodeMontage)
.Format("dd/MM/yyyy")
);
columns.Select()
.Title(ResourcesRR.lblSelection)
.Width(80)
.HeaderHtmlAttributes(new { style = "text-align: center; justify-content: center;" })
.HtmlAttributes(new { style = "text-align: center;" })
.HeaderTemplate(p => ResourcesRR.lblSelection);
})
.Events(ev => ev.Change("soumissionFinancement.onSubmitChangeSelection"))
.BindTo(Model)
)
And this is the javascript to get the selected itens:
onSubmitChangeSelection = (arg) => {
let self = this;
let rows = arg.sender.select();
this.submitSelectedItems = [];
rows.each(function (e) {
let grid = $("#ListeMontagesResults").data("kendoGrid");
let dataItem = grid.dataItem(this);
self.submitSelectedItems.push(dataItem);
});
}
The problem happend in those lines, since the grid when local binded does not appears to keep the dataSource:
let grid = $("#ListeMontagesResults").data("kendoGrid");
let dataItem = grid.dataItem(this);