【问题标题】:Kendo Ui Grid disable button when in edit inline mode处于编辑内联模式时的 Kendo Ui Grid 禁用按钮
【发布时间】:2015-04-07 02:13:44
【问题描述】:

我有一个带有创建、编辑和删除按钮的剑道网格。我在网格外还有一个下一步按钮。如果用户至少没有先创建/编辑一条记录,我想要做的是阻止用户点击下一步按钮。

<div ng-show="showActivePage === 'PageTwo'" ng-controller="inputFiscalYearController" >
    <div kendo-grid="myGrid"   k-options="gridOptionsFiscalYear" ></div> 

    <div ng-click="showActivePage = 'PageThree'"> Next </div>
    <div ng-click="showActivePage = 'PageOne'"> Back </div>
</div>


app.controller('inputFiscalYearController', ['$scope', function ($scope) {
$scope.isDisabled = false;
$scope.gridOptionsFiscalYear = {
    toolbar: ["create"],
     editable: true,
     pageable: true,
     edit: function(){
         alert();

     },

     columns: [
             {
                 field: "Name",
                 title: "Name",
                 width: "250px",
             },
             {
                 field: "Surname",
                 title: "Surname",
                 width: "250px",

             },
              {
                  title: "",
                  command: ["edit", "destroy"],
                  width: "105px"
              },
    ],
    editable: "inline",

    dataSource: {
        data: [

        ],
        pageSize: 10,
        schema: {
            model: {
                id: "id",
                fields: {
                    id: { editable: false },

                    Name: {
                        type: "string",
                        validation: {
                            required: {
                                message: "*Required"
                            }
                        }
                    },
                    Surname: {
                        type: "string",
                        validation: {
                            required: {
                                message: "*Required"
                            }
                        }
                    },
                }
            }
        }
    },
}
}]);

【问题讨论】:

    标签: javascript html button kendo-ui kendo-grid


    【解决方案1】:

    我不熟悉 kendo-ui,但我知道 Angular。你就不能这样做吗:

    <div ng-click="showActivePage = 'PageThree'" disabled="!gridOptionsFiscalYear.data.length"> Next </div>
    

    我假设 gridOptionsFiscalYear.data 是创建新记录的地方。

    编辑:在长度上没有必要的否定。

    【讨论】:

    • 是的。它用于添加新记录。我尝试了您的解决方案,但我得到一个空白页。我同时做的是,我首先隐藏下一个按钮,然后在 SAVE 事件中,我只是显示它。但我需要先禁用它,然后在 SAVE 事件中启用它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多