【问题标题】:Making one column editable with x-kendo-template使用 x-kendo-template 使一列可编辑
【发布时间】:2018-08-23 20:51:00
【问题描述】:

我正在使用 x-kendo-template 并使用函数使列在点击时可编辑。它所做的是擦除按钮,使所有列都可编辑,即使我已经在架构中指定了我想要保持为假的字段。

<div id="grid"></div>
var dataSource = new kendo.data.DataSource(
    transport:{
        read: function(options){
            // code
        },
        update: function(options){
            // code
        },
        cancel: function(options){
            // code
        },
        parameterMap: function (options, operation) {
            if (operation !== "read" && options.models) {
                return { models: kendo.stringify(options.models) };
            }
        },
        schema: {
            model: {
                id: "grid",
                fields: [
                    Name: { type: "string", editable: false },
                    Value: { type: "string" }
                ] 
            }
        }
    }
);  


<script id="template" type="text/x-kendo-template">
  <a class="k-button k-button-icontext k-grid-update k-cust-update k-state-selected"><span class="k-update"></span>Update</a>
  <a class="k-button k-button-icontext k-grid-cancel k-cust-cancel k-state-selected"><span class="k-cancel"></span>Cancel</a>
</script>

$('.k-grid-update').on('click', function(){       
  $("#grid").data("kendoGrid").setOptions({ editable: true });
});

因此,基于此,单击按钮后,名称不应可编辑,而值应不可编辑。

【问题讨论】:

  • schema.model id: 值可能不正确。 id: 值应该是数据记录中唯一标识每一行的字段的名称——在您的情况下,它可以是 Name,或者可能是其他字段,例如 rowId,它是数据库表。
  • 您没有显示网格创建代码。你能用本地数据来创建一个可以工作的 Dojo 来证明这个问题吗?

标签: kendo-ui kendo-grid


【解决方案1】:

问题不清楚,我不明白你在哪里卡,但也许这可以帮助你

http://dojo.telerik.com/oXAjI/2

此示例使用 x-kendo-tmpl,您可以使用以下命令禁用一个列的编辑

数据源 -> 架构 -> 模型 -> 字段 -> -> 可编辑:false

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-03
    • 2016-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多