What I am trying to do.. is create this grid of CartLines, display them, and allow editing of ONLY the quantity field.
This grid below displays, and is editable (presumably, I haven't implemented the update action but the UI appears to work).
The moment I added .Editable(false) to any of the model.Fields, I get an error that the object is not referring an object ..
>> Object reference not set to an instance of an object.
and that happens before it even tries to call the read action. And I am quite surprised about the behavior on the first column, the picture column. That field is editable also which surprised me. I mean.. I guess i didn't tell it not to.. But it is clearly associating it with the modeId and I would think the modelid is sacred and shouldn't be changed.
Anyway... what's the best way to accomplish this?
Quantity should be editable
Nothing else should be editable.
(though I may add a delete the entire row option)
@(Html.Kendo().Grid<EveShop.Domain.Entities.CartLine>() .Name("cartGrid") .DataSource( dataSource => dataSource .Ajax() .Read(read => read.Action("GetCartList", "Cart").Data("additionalCartListData")) .Model(model => {
model.Id(p => p.Product.ProductID);
model.Field(p => p.Product.Name); model.Field(p => p.Quantity); model.Field(p => p.Product.Price)/*.Editable(false)*/; }) ) .Columns(columns => { // this first column is really just a picture column, may be a better way to do this
// than binding it to Product.ProductID? to an empty field? didn't see how to do that.
columns.Bound(line => line.Product.ProductID).ClientTemplate("<img src='" + Url.Content("~/Images/Types/") + "#:Product.ProductID#_64.png' alt='#: Product.ProductID #' />").Title("Picture"); columns.Bound(line => line.Product.Name); columns.Bound(line => line.Quantity); columns.Bound(line => line.Product.Price); }) .Editable(editable => editable.Mode(GridEditMode.InCell)) )