【问题标题】:Changing column data in kendo grid conditionally有条件地更改剑道网格中的列数据
【发布时间】:2017-08-18 07:09:32
【问题描述】:

我正在尝试有条件地更改剑道网格中某些列的值。由于网格 id 已经绑定到一些数据,但它需要一些修改 已经绑定的数据。

我使用了几个从 stackoverflow 获得的示例代码,但没有一个反映。网格数据没有变化

第一种方式

var grid = $("#grid").data("kendoGrid");

            var items = grid.dataSource.data();
            for (var i = 0; i < items.length; i++) {
                items[i]["MatchCount"] = "4";
            }

第二种方法尝试

var dataItem = $("#grid").data("kendoGrid").dataSource.data()[0];
        dataItem.set("MatchCount", "CCC");

第三种方式

  var dataItem = $("#grid").data("kendoGrid").dataSource.data()[0];
     dataItem.set("MatchCount", "50");

网格的绑定方式如下:

  $("#grid").kendoGrid({
        dataSource: DataSource,

        columns:
        [
            { field: "RowId", title: "RowId", hidden: true },
            {
                field: "LastName",
                title: "Last Name",
                width: 150,
                editable: false,
                headerTemplate: createHeaderTemplate("Last Name")

            },
           {
                field: "MatchCount",
                width: 120,
                editable: false,
                template: "#if(MatchCount == 0){#<span>#=MatchCount#</span>#}else{#<a href='javascript:void(0)' onclick='ShowMatches(&quot;#=LastName#&quot;,&quot;#=FirstName#&quot;,${MatchCount},&quot;#=MatchIds#&quot;);' style='margin-left:50px' >#=MatchCount#</a>#}#"
            }

        ],
        edit: function (e) {
            //e.container.find("input[name='Name']").each(function () { $(this).attr("disabled", "disabled") });       
        },
        editable: false
    });

【问题讨论】:

    标签: jquery kendo-ui kendo-grid


    【解决方案1】:

    您在尝试 2 和 3 中做得很好。也许您需要运行 refresh() 方法:

    dataItem.set("MatchCount", "50");
    grid.refresh();
    

    Demo

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-15
      • 1970-01-01
      • 1970-01-01
      • 2016-11-03
      • 1970-01-01
      • 2013-05-22
      相关资源
      最近更新 更多