我想在第一行插入剑道网格时禁用第二列,而不是在此之后

时间:2016-10-04 22:27:47

标签: javascript jquery kendo-ui kendo-grid

我有一个带工具栏创建的kendo ui网格。

在那里,我想在插入第一行时禁用第二列 从第2行开始,我希望启用该列 我还想在网格中的每个插入的第一列中插入计数。

例如:如果插入第一行,我希望第一列为"第1层"。
如果插入第2行,那么我希望第1列为"第2层"。
如果超过3,则删除第2行...我希望第3行第1列转换为"第3层"到"第2层"。

有人可以帮助我实现这个目标吗? 我正努力在剑道网格中有这么多的控​​制权 以下是代码:

 var rateScheduleItemGridDatasource = new kendo.data.DataSource({
    transport: {
        read: {
            type: 'get',
            url: config.apiServer + "api/RateSchedule/GetAllRateScheduleItems?rateScheduleId=" + selectedRateScheduleId,
            dataType: "json"
        },
        destroy: {
            type: 'delete',
            url: function (options) {
                alert('hi');
                $.ajax({
                    url: config.apiServer + "api/RateSchedule/DeleteRateScheduleItem?rateScheduleItemId=" + options.RateScheduleItemId,
                    type: 'delete',
                    data: ko.toJSON(options),
                    contentType: "application/json",
                    success: function (data) {
                        popupNotification.show(updateSuccessMessage, "success");
                        rateScheduleItemGridDatasource.read();
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        popupNotification.show(updateFailureMessage, "error");
                    }
                });
            },
            dataType: "json",
            contentType: "application/json"
        }
    },
    serverPaging: false,
    serverSorting: false,
    serverFiltering: false,
    serverGrouping: false,
    serverAggregates: false,
    batch: true,
    schema: {
        data: "Data",
        total: "Total",
        errors: "Errors",
        model: {
            id: "RateScheduleItemId",
            fields: {
                RateScheduleItemId: { type: "number", editable: false, nullable: false },
                RateScheduleId: { type: "number", editable: false, nullable: false, validation: { required: true } },
                MathmetricalSymbolCode: { type: "number", nullable: true, editable: true, validation: { required: false } },
                MathmetricalSymbolCodeValue: { type: "string", nullable: true, editable: true, validation: { required: false } },
                MeasureTypeCode: { type: "number", nullable: true, editable: true, validation: { required: false } },
                MeasureTypeCodeValue: { type: "string", nullable: true, editable: true, validation: { required: false } },
                MultiplierRate: { type: "number", nullable: true, editable: true, validation: { required: false } },
                RangeLowerNumber: { type: "number", nullable: true, editable: true, validation: { required: false } },
                RangeUpperNumber: { type: "number", nullable: true, editable: true, validation: { required: false } },
                RateTier: { type: "string", nullable: true, editable: false, validation: { required: false } }
            }
        }
    }
});
 $("#rateScheduleItemGrid").kendoGrid({
    columns: [
        { "command": [{ name: "destroy", text: "&nbsp" }], "width": "60px" },
        { "title": "Rate Tier", "width": "100px", "field": "RateTier" },
        { "title": "Operand", "width": "100px", "field": "MathmetricalSymbolCodeValue", "editor": rateScheduleItemOperandDropDownEditor, values: rateScheduleItemOperandReferenceData },
        { "title": "Range (From)", "width": "100px", "field": "RangeLowerNumber" },
        { "title": "Range (to)", "width": "100px", "field": "RangeUpperNumber" },
        { "title": "Rate (Multiplier)", "width": "100px", "field": "MultiplierRate" }
    ],
    resizable: true,
    editable: true,
    editable: {
        createAt: "bottom"
    },
    groupable: false,
    filterable: false,
    pageable: false,
    sortable: false,
    scrollable: true,
    height: 200,
    dataSource: rateScheduleItemGridDatasource,
    cancel: function (e) {
        dirty = false;
    },
    save: function (e) {
        dirty = false;
    }
});

使用下面的代码,我点击一个单独的按钮,我在网格中添加一个新行 我没有使用Kendo ui网格内置工具栏功能。

 $('#AddAnotherTier').click(function () {
    if (selectedRateScheduleId === 0) {
        var grid = $("#rateScheduleItemGrid").data("kendoGrid");
        grid.addRow();
        if (grid.dataSource.total() == 1) {
            //To do - make the operand column disabled
        }
    }
});

并且RateTier将是我想在客户端更新其文本的第一列,按照逐个插入的行。

0 个答案:

没有答案