I am showing multiple instances of the same grid in the same view. And everything works fine except if you try to edit a record on two grids at the same time.
The problem seems to be that the EditorFor elements created when switching to in-line edit mode all end up named the same, so the second set of editors don't work as expected (as-in, the DatePicker doesn't render, I just end-up with a non-formatted date in a regular textbox).
I tried adding an HtmlFieldPrefix to each partial (the helper to create the view is held within a PartialView that's called for each team).
That makes the actual editors render appropriately, but they don't get properly bound to the underlying model (as-in, I can see the datepicker, but it doesn't have the existing value, nor posts back to the model as expected).
As far as the model, the key portion would be with the Date fields, where I have the model decorated so that it shows the appropriate date picker.
The way I'm creating multiple grids is that I loop through a collection of teams and call a helper to create each grid with a separate Id.
[DisplayFormat(DataFormatString =
"{0:MM/dd/yyyy}"
, ApplyFormatInEditMode =
true
)]
[UIHint(
"Date"
)]
public
DateTime DateStart {
get
;
set
; }
@helper TeamGrid(
int
id)
{
@(Html.Kendo().Grid<KTeam>()
.Name(
"gridTeam"
+ id)
.DataSource
(
d => d
.Ajax()
.ServerOperation(
false
)
.PageSize(20)
.Model(model => {
model.Id(u => u.Id);
})
.Events(events => events.Error(
"onError"
))
.Read(r => r.Action(
"ReadTeam"
,
"Report"
).Data(
"dataTeamId("
+ id +
")"
))
.Update(u => u.Action(
"EditTeam"
,
"Report"
))
.Sort(sort => sort.Add(s => s.Member).Ascending())
)
.Columns(columns => {
columns.Bound(u => u.Id).Hidden();
columns.Bound(u => u.Member).Width(200);
columns.Bound(u => u.DateStart).Width(120);
columns.Bound(u => u.DateEnd).Width(120);
columns.Command(command => command.Edit()).Width(177);
})
.Filterable(f => f.Extra(
false
).Operators(o => o.ForString(s => s.Clear().Contains(
"Contains"
))))
.Sortable(s => s.SortMode(GridSortMode.MultipleColumn).AllowUnsort(
true
))
) }