簡體   English   中英

Kendo網格下拉列表問題

[英]Kendo grid dropdownlist issue

我在Kendo網格中的一列上使用自定義模板。 一切都很好,當檢索數據時,下拉列表顯示正確的值。 但是,當我單擊編輯命令時,該行變為編輯模式,並且下拉列表未顯示其值。 僅當我單擊下拉列表時,該項目才會顯示為選中狀態。 我要的是在編輯模式下顯示文本。

單擊之前編輯 在此處輸入圖片說明

單擊后編輯 在此處輸入圖片說明

我的代碼:

function customDdlEditor(container, options) {
    $('<input required data-text-field="text" data-value-field="value"  data-bind="value:' + options.field + '"/>')//data-text-field="text" data-value-field="value" data-bind="value:fieldType"
   .appendTo(container)
   .kendoDropDownList({
       autobinds: false,
       dataTextField: "text",
       dataValueField: "value",           
       dataSource: ddl

   });
 }

var ddl = [{ text: "Text", value: "Text" },
        { text: "Date", value: "Date" },
        { text: "Number", value: "Number"}];

var Grid = $("#grid").kendoGrid({
            dataSource: fieldDataSource,                
            columns: [
        ...
        { field: "type", title: "Type", editor: customDdlEditor, template: "#= type #" },
        ...
        ,
            noRecords: true,
        }).data("kendoGrid");

        var fieldDataSource = new kendo.data.DataSource({
            data: gridData,
            pageSize: 50,
            schema: {
                model: {
                    id: "name",
                    fields: {
                        ...,
                        type: { field: "type"},
                        ...
                    }
                }
            }
        });

有人知道如何解決嗎?

如果您使下拉菜單中的autoBind:true起作用。

function customDdlEditor(container, options) {
    $('<input required data-text-field="text" data-value-field="value"  data-bind="value:' + options.field + '"/>')//data-text-field="text" data-value-field="value" data-bind="value:fieldType"
   .appendTo(container)
   .kendoDropDownList({
       autobinds: true, // <-- auto bind true instead
       dataTextField: "text",
       dataValueField: "value",           
       dataSource: ddl

   });
 }

暫無
暫無

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

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