Kendo UI网格条件编辑 [英] Kendo UI Grid Conditional editing

查看:85
本文介绍了Kendo UI网格条件编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为某些CatalogProductId禁用DiscountPercentageMRC/NRC/Usage列.请在下面的javascript表格中查找.任何帮助将不胜感激.

I would like to disable DiscountPercentageMRC/NRC/Usage columns for certain CatalogProductId's. Please find below javascript for the grid. Any help would be greatly appreciated.

<h2>Kendo Grid bound to ASP.NET MVC action methods</h2>
@* The DIV where the Kendo grid will be initialized *@
<div id="grid"></div>
<script>
  $(document).ready(function () {
     $("#grid").kendoGrid({
         columns: [
         { field: "CompanyId"},
         { field: "CompanyName" },
         { field: "DiscountPercentageMRC" },
         { field: "CatalogProductId"},
         { field: "DiscountPercentageMRC" },
         { field: "DiscountPercentageNRC" },
         { field: "DiscountPercentageNRC" },
         { field: "DiscountPercentageUsage"}
         ],
        height: 400,
        editable: true, // enable editing
        pageable: true,
        sortable: true,
        filterable: true,
        toolbar: ["create", "save", "cancel","edit"], // specify toolbar commands
        dataSource: {
            serverPaging: true,
            serverFiltering: true,
            serverSorting: true,
            pageSize: 10,
            batch: true, 
            editable: "inline",
            transport: {
                read: {
                    url: "@Url.Action("ResellerDiscountsGet", "AccountDetail", new {                     BusOrdId = @ViewBag.Message })",
                    type: "POST",

                }
            }
        },

        selectable: true
    });

     });

   </script>

推荐答案

您将使用Edit事件启用/禁用单元格.我在这里创建了一个工作示例: http://jsfiddle.net/Eh8GL/151/

You would use the Edit event to enable/disable cells. I created a working example here: http://jsfiddle.net/Eh8GL/151/

function OnEdit(e) {
    // Make sure it's not a new entry
    if (!e.model.isNew()) {
        var catalogproductid =  e.container.find("input[name=CatalogProductId]").data("kendoNumericTextBox").value();

        // Disable DiscountPercentageMRC if catalog productid = 100
        if (catalogproductid == 100) {
            var disableField = e.container.find("input[name=DiscountPercentageMRC]").data("kendoNumericTextBox");
            disableField.enable(false);
        }
    }
}

这篇关于Kendo UI网格条件编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆