I have a grid with batch editing enabled and have got it working very well. This particular gird deals with line items in an order.
So when the user clicks Add New item they enter the part number description and other pertinent info and click save. No problem.
The problem is that once we save the item, we do not want to have the part number field to be editable. If they need to change the part number they should have to delete the line item and add it again.
I am trying to figure out how to make this field not editable on the on edit event but can't figure it out. I have some java script for the edit event commented out in my code that was suppose to deal with another issue but it crashes. I know I am on the right path but can't take it in for the score. The java script I have commented out is in the next code block.
Any help is appreciated...
So when the user clicks Add New item they enter the part number description and other pertinent info and click save. No problem.
The problem is that once we save the item, we do not want to have the part number field to be editable. If they need to change the part number they should have to delete the line item and add it again.
I am trying to figure out how to make this field not editable on the on edit event but can't figure it out. I have some java script for the edit event commented out in my code that was suppose to deal with another issue but it crashes. I know I am on the right path but can't take it in for the score. The java script I have commented out is in the next code block.
Any help is appreciated...
@(Html.Kendo().Grid<
BuyItNow.Models.LineItemViewModel
>().HtmlAttributes(htmlAttributes)
.Name("kendoGrid")
.EnableCustomBinding(true)
.BindTo(Model.Data)
.Events(events => events.DataBound("dataBound"))
.Columns(columns =>
{
columns.Bound(p => p.lineNumber);
columns.Bound(p => p.partNum).Title("Part#").EditorTemplateName("PartNumber");
columns.Bound(p => p.partDescription).EditorTemplateName("Description");
columns.Bound(p => p.unitOM).EditorTemplateName("UOM").Equals("EA");
columns.Bound(p => p.partQuant).EditorTemplateName("Number").Format("{0:n0}");
})
.ToolBar(toolbar =>
{
toolbar.Create();
toolbar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable()
.Sortable()
// .Scrollable()
.Navigatable()
.DataSource(dataSource => dataSource
.Ajax()
.Total(Model.Total)
.Batch(true)
.ServerOperation(false)
.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(p => p.itemID);
model.Field(p => p.lineNumber).Editable(false).DefaultValue("0000");
})
.Create(update => update.Action("_Create", "LineItems"))
.Read(read => read.Action("_Read", "LineItems"))
.Update(update => update.Action("_Update", "LineItems"))
)
.Resizable(resize => resize.Columns(true))
$(document).ready(
function
() {
var
grid = $(
"#kendoGrid"
).data(
"kendogrid"
);
// bind to the edit event
grid.bind(
"edit"
,
function
(e) {
debugger;
e.preventDefault();
e.container.find(
'input:last'
).focus()
}
});