Hi,
I am trying to implement a Grid with inline editing capability. Everything works fine except for the Create functionality. I am using a string for the Model Id.
Here is what happens..
1) Click on Add New Record
2) Add a record in the client
3) Update any information
4) Clicking Update fires the Update action instead of create.
This is the example I am following: http://demos.telerik.com/aspnet-mvc/grid/editing-inline
I am not sure why the update action is being fired instead of create.
Could this be because of the Model Id is a string.
Below is a code snippet of the kendo grid.
Most of the code above is same telerik grid inline editing example except for the model.
Any thoughts?
I am trying to implement a Grid with inline editing capability. Everything works fine except for the Create functionality. I am using a string for the Model Id.
.Model(model =>
{
model.Id<
string
>(p => p.SalesRep.Id);
}
Here is what happens..
1) Click on Add New Record
2) Add a record in the client
3) Update any information
4) Clicking Update fires the Update action instead of create.
This is the example I am following: http://demos.telerik.com/aspnet-mvc/grid/editing-inline
I am not sure why the update action is being fired instead of create.
Could this be because of the Model Id is a string.
Below is a code snippet of the kendo grid.
@(Html.Kendo().Grid<SalesRepViewModel>()
.Name(
"SalesRepsGrid"
)
.Columns(columns =>
{
columns.Bound(p => p.SalesRep).ClientTemplate(
"#=data.SalesRep.Name#"
);
columns.Bound(p => p.SplitPercentage).Width(100);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(172);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error(
"error_handler"
))
.Model(model =>
{
model.Id<
string
>(p => p.SalesRep.Id);
model.Field(p => p.SalesRep.Id).Editable(
false
);
model.Field(p => p.SplitPercentage).Editable(
true
);
model.Field(p => p.SalesRep).DefaultValue(
ViewData[
"defaultSalesRep"
]
as
NamedReferenceBindingModel<
string
>);
})
.Read(read => read.Action(
"SalesReps_Read"
,
"PurchaseAgreement"
))
.Create(update => update.Action(
"SalesReps_Create"
,
"PurchaseAgreement"
,
new
{ purchaseAgreementId = Model.Id }))
.Update(update => update.Action(
"SalesReps_Update"
,
"PurchaseAgreement"
,
new
{ purchaseAgreementId = Model.Id }))
.Destroy(destroy => destroy.Action(
"SalesReps_Destroy"
,
"PurchaseAgreement"
,
new
{ purchaseAgreementId = Model.Id }))
)
)
Most of the code above is same telerik grid inline editing example except for the model.
Any thoughts?