简体   繁体   中英

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

I have following config foo column in grid:

field:

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

Column:

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

Which works almost fine, but if i clicked on cell item i always got following value (see. image below), instead of the text defined in template attribute.

在此处输入图片说明

How can i solve it please?

Many thanks for any advice.

It might not be the cleanest way, but you could use the edit event like I do in this blog post .

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

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

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

Although as I note in that post, setting the default value with .set() might not work in this case, and you might need to edit the text in the edit box directly:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM