首页 文章

如何为Angular创建Kendo网格的动态单元格

提问于
浏览
0

我有一个Kendo网格,根据数据,我需要在一列中使用不同的输入控件 . 我有三种情况:

  • 如果值为 true ,则复选框应出现在编辑状态 .

  • 如果值为 stringnumber ,则应编辑文本框

  • 如果值为“更多”,则应编辑超链接 .

enter image description here

请参阅上面的截图 .

1 回答

  • 2

    在模板中,您可以在其中定义列,您可以为单元格使用自定义模板 . 在这里你可以写一些条件来决定渲染什么:

    <kendo-grid-column field="example" title="Example" width="100">
        <ng-template kendoGridCellTemplate let-dataItem>
            <!-- You can use ngIf and/or ngSwitch here. -->
        </ng-template>
    </kendo-grid-column>
    

    API:https://www.telerik.com/kendo-angular-ui/components/grid/api/CellTemplateDirective/

相关问题