if I change GridEditMode.PopUp to GridEditMode.InLine it works, but when it is in PopUp mode, it throws following error
The model item passed into the dictionary is of type 'OfficeGx.Pms.Model.WorkStatus', but this dictionary requires a model item of type 'System.Int32'.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'OfficeGx.Pms.Model.WorkStatus', but this dictionary requires a model item of type 'System.Int32'.
Source Error:
Line 1: @using OfficeGx.Pms.Model.NonDb Line 2: @(Html.Kendo().Grid<OfficeGx.Pms.Model.WorkStatus>() Line 3: .Name("WorkStatusGrid")
Line 4: .Columns(columns =>
Source File: Status.cshtml Line: 2
Here is my Grid Code
@
using
OfficeGx.Pms.Model.NonDb
@(Html.Kendo().Grid<OfficeGx.Pms.Model.WorkStatus>()
.Name(
"WorkStatusGrid"
)
.Columns(columns =>
{
columns.Bound(c => c.Id);
columns.Bound(c => c.Name);
columns.Bound(c => c.Style.BackgroundColor).ClientTemplate(
"# if(typeof Style!='undefined') { #<span>#:Style.BackgroundColor#</span># } else { #''# }#"
);
columns.Bound(c => c.Description).Width(150);
columns.Bound(c => c.DisplayOrder);
columns.Bound(c => c.CreatedDateUtc).Format(
"{0:dd/MM/yyyy HH:mm}"
);
columns.Bound(c => c.ModifiedDateUtc).Format(
"{0:dd/MM/yyyy HH:mm}"
);
columns.Bound(c => c.IsDefault).EditorTemplateName(
"BooleanForWorkConfigDefault"
)
.HtmlAttributes(
new
{ @
class
=
"default-checkbox-status"
});
columns.Command(command =>
{
command.Edit().Text(
" "
);
command.Destroy().Text(
" "
);
});
})
//.Scrollable()
.Groupable()
.Sortable().ColumnMenu()
.ToolBar(toolbar =>
{
toolbar.Create();
//toolbar.Save();
})
.Editable(editable =>
editable.Mode(GridEditMode.InLine)
.Window(x => x.Width(600).Title(
"Add/Edit Status"
)))
.Pageable(pageable => pageable
.Refresh(
true
)
.PageSizes(
true
)
.ButtonCount(5))
.Resizable(resize => resize.Columns(
true
))
.Reorderable(reorder => reorder.Columns(
true
))
.DataSource(dataSource => dataSource
.Ajax()
.Sort(sort => sort.Add(x => x.DisplayOrder).Ascending())
.Batch(
true
)
.Model(model =>
{
model.Id(x => x.Id);
model.Field(c => c.Id).DefaultValue(0).Editable(
false
);
model.Field(x => x.Name).Editable(
true
);
//model.Field(x => x.Style).DefaultValue(new Style()).Editable(true);
model.Field(x => x.Style.BackgroundColor).Editable(
true
);
model.Field(x => x.DisplayOrder).Editable(
true
);
model.Field(c => c.Description).Editable(
true
);
model.Field(c => c.CreatedDateUtc).Editable(
false
);
model.Field(c => c.ModifiedDateUtc).Editable(
false
);
})
.Events(events => events.Error(
"workConfig.gridErrorHandler"
))
.Read(read => read.Action(
"ReadStatus"
,
"Config"
,
new
{ area =
"Pms"
}))
.Create(update => update.Action(
"AddStatus"
,
"Config"
,
new
{ area =
"Pms"
}))
.Update(update => update.Action(
"UpdateStatus"
,
"Config"
,
new
{ area =
"Pms"
}))
.Destroy(update => update.Action(
"DeleteStatus"
,
"Config"
,
new
{ area =
"Pms"
}))
.PageSize(20)
))