簡體   English   中英

Kendo Grid:內聯編輯模式下單元格的默認值為1,如何更改?

[英]Kendo Grid : Default value 1 in cell in inline edit mode, how to change it?

我在網格中有以下config foo列:

領域:

   actionName: {
                    editable: true,
                    nullable: true,
                    defaultValue: {"name" : "TEST123"},
                    type: "object"
                  },

柱:

{ 
                field :"actionName",
                title : $translate.instant('ACTIONNAME'),
                width: "200px",
                editor: GlobalHelperService.getActionNamesListForAutocomplete,
                template: '#: data.actionName.name #',
                filterable: { cell: { operator:"contains"
                    }
                }
            },

這幾乎可以正常工作,但是如果我單擊單元格項目,我總是得到以下值(參見下圖),而不是模板屬性中定義的文本。

在此處輸入圖片說明

我該如何解決?

非常感謝您的任何建議。

這可能不是最干凈的方法,但是您可以像在本博文中一樣使用edit事件。

$("#grid").kendoGrid({
    edit: onEdit
});

function onEdit(editEvent) {
    // Ignore edits of existing rows.
    if(!editEvent.model.isNew()) { return; }

    editEvent.model.set("actionName", {name: "TEST123"});
}

盡管正如我在.set()文章中指出的那樣,在這種情況下,使用.set()設置默認值可能不起作用,並且您可能需要直接在編輯框中編輯文本:

editEvent.container
         .find("[name=actionName]")
         .val("TEST123")
         .trigger("change");

暫無
暫無

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

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