代码之家  ›  专栏  ›  技术社区  ›  Chris

在Kendo UI网格中添加新行时如何使用模板?

  •  0
  • Chris  · 技术社区  · 8 年前

    当我向剑道网格添加一行时,我需要能够在一个单元格中使用一个模板,但不知道如何做到这一点。 添加我使用的新行

    grid.dataSource.insert(0, { AreaID: null, AreaName: "New Area", Catalog: 2 });
    

    但我要做的是在目录上,我需要添加一个下拉列表。我试过这样的测试

    grid.dataSource.insert(0, { AreaID: null, AreaName: "New Area", Catalog: '<div>acd</div>' });
    

    但我的目录列显示为未定义。

    在添加新行时,如何向catalog列添加下拉列表?

    1 回复  |  直到 8 年前
        1
  •  0
  •   Pooja Suryawanshi    8 年前

    可以使用以下代码行在网格中添加列

     $("#grid").kendoGrid({
              dataSource: dataSource,
    
              pageable: true,
              height: 430,
              toolbar: ["create", "save", "cancel"],
              columns: [
    
                { template: "<input data-bind='value:ProductName' />", title: "Product Name", width: 110 },
                { template: "<input data-bind='value:UnitsInStock' />", title: "Units In Stock", width: 110 },
                { field: "Discontinued", width: 110 },
                { command: "destroy", title: "&nbsp;", width: 90 }],
              editable: true,
              dataBound: onDataBound
            }); 
    

    更多详情: We can refer the Kendo Document