Asp.net mvc 4 剑道UI网格积垢多次发射
我的页面中有一个剑道UI网格。下面是带有CRUD数据源操作的KendoUIGrid代码Asp.net mvc 4 剑道UI网格积垢多次发射,asp.net-mvc-4,post,kendo-ui,grid,crud,Asp.net Mvc 4,Post,Kendo Ui,Grid,Crud,我的页面中有一个剑道UI网格。下面是带有CRUD数据源操作的KendoUIGrid代码 @(Html.Kendo().Grid<Gts.GlaspacLX.Web.ViewModel.ProductViewModel>() .Name("xyzGrid") .Columns(columns => { columns.Bound(p => p.SelectedProductCategory).Edito
@(Html.Kendo().Grid<Gts.GlaspacLX.Web.ViewModel.ProductViewModel>()
.Name("xyzGrid")
.Columns(columns =>
{
columns.Bound(p => p.SelectedProductCategory).EditorTemplateName("_ProductDropDownList").Title("Product Category").HtmlAttributes(new { @tabindex = "8" });
columns.Bound(p => p.Name).Width(130).Title("% Off").HtmlAttributes(new { @tabindex ="9" });
columns.Bound(p => p.Rate).Width(130).HtmlAttributes(new { @class = "prodDiscRtAlign",@tabindex= "10" });
columns.Bound(p => p.Hours).Width(130).HtmlAttributes(new { @class = "prodDiscRtAlign",@tabindex= "11" });
if (SiteContext.CurrentUser.HasPrivilege(PrivilegeNames.Maintenance, PermissionNames.DELETE))
{
columns.Command(command => { command.Destroy(); }).Width(110).Title("Delete").HtmlAttributes(new { @tabindex = "12" });
}
})
.ToolBar(commands =>
{
commands.Create();
commands.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom))
.Sortable()
.Navigatable()
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Model(model =>
{
model.Id(p => p.ProductID);
model.Field(p => p.SelectedProductCategory).DefaultValue(ViewBag.DefaultProductCategory);
})
.Read(read => read.Action("Product_Read", "ProductController"))
.Update(update => update.Action("Product_Update", " ProductController "))
.Create(create => create.Action("Product_Create", " ProductController "))
.Destroy(update => update.Action("Product_Destroy", " ProductController ")
))
.Events(e => e.Edit("proField").DataBound("boundProductChange"))
)
}插入任何记录后,您应返回主键(Id)进行查看。
参见剑道演示。你能分享
proField
函数的代码吗?@EfrainReyes我添加了proField函数。你能分享“boundProductChange”吗too@Pawan我仍然看不出代码有问题。你能分享整个视图/布局吗?嘿,我知道这是旧的,但我有一个非常类似的问题。你找到发生什么事了吗?@lraj我用返回的随机数检查了一下。但结果是一样的。问题是,事件在单击“保存”按钮时触发。这意味着一旦我们单击“保存”按钮,就会触发多个事件。你确定吗?我对此一无所知。选中此项:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Product_Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<ProductViewModel> product){
return Json(results.ToDataSourceResult(request, ModelState));
}
function proField(e) {
var defaultproduct = $("#DefaultProductCategory").val();
defaultproduct = "\n" + defaultproduct + "select ";
if (e.model.SelectedProductCategory == "Default" && (e.sender._editContainer[0].textContent == defaultproduct || e.sender._editContainer[0].textContent == "\n select ")) {
e.sender._editContainer[0].disabled = true;
e.sender._editContainer[0].children[0].textContent = "Default";
e.sender.table[0].rows[1].cells[1].click();
e.sender.table[0].rows[1].cells[4].disabled = true;
}