簡體   English   中英

如何在Kendo Grid中切換模板列

[英]How to switch template column in Kendo Grid

我有一個Kendo網格,其中有一個下拉菜單的模板列。 如何切換模板列以在某些行上使用其他控件? 這是我的網格所擁有的

function OrderEntryOptions() {
$("#orderEntryOptions").kendoGrid({
    columns: [{
        field: "Options",
        title:"Options"
    },
    {
        field: "SelectAreas",
        template: '<select class="form-control" ><option>False</option><option>True</option></select>',
    }],
    dataSource: {
        data: [{
            Options: "Show Self Note Column"
        },
        {
            Options: "Ctrl+C, Ctrl-V for Excel Commands"
        },
        {
            Options: "Validation: Show Yellow Alerts when Printing"
        },
        {
            Options: "Default Import/Export Directory"
        },
        {
            Options:"Show Sq. Ft. on screen"
        },
        {
            Options: "Process Global Defaults"
        },
        {
            Options: "Catalog Tree Auto-Expand"
        },
        {
            Options: "Hide Sections column in Globals"
        },
        {
            Options:"First column in blank row to get focus"
        },
        {
            Options: "Search on item name only"
        }
        ]
    }
});
}

在“我的選項”列中顯示“默認導入/導出目錄”,我需要刪除下拉列表並使用按鈕,然后在“我的選項”列中顯示“空白行中的第一列以獲取焦點”,我需要進行更改從True / False到另一個網格的列名的下拉列表中的值。

您可以使用以下方法指定模板:

<script id="rowTemplate" type="text/x-kendo-tmpl">    
</script>

在網格定義中更改:

template: '<select class="form-control" ><option>False</option><option>True</option></select>'

至:

 kendo.template($("#rowTemplate").html()

在此模板內,您可以添加條件,例如:

  <script id="rowTemplate" type="text/x-kendo-tmpl">
        # if (Options== "Default Import/Export Directory") { #
        <button id="button_id">Button text</button>
        # } else { #
         <select class="form-control" ><option>False</option><option>True</option></select>
        # } #            
    </script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM