kendo 下拉列表中的网格值在未处于编辑模式时显示为未定义

kendo grid value from dropdownlist shows as undefined when not in edit mode

参见此处示例:http://dojo.telerik.com/ihIco

我确定我可以正常工作,但我不知道我更改了什么。

当您进入编辑模式并选择第一项(即空白的 optionLabel 项)然后单击更新时,网格显示 "undefined"。

您的问题与您的模板有关,该模板需要绑定到对象品牌上的 属性 名称。

template: function()"#= Brand.name #",

因为您的网格数据源中没有空白值 ​​Brand 的项,在这种情况下将为空。

  dataSource:  {
                data: [
                    { Brand: {id: 1, name: "Ford"} } 
                ],
                schema: {
                    model: {
                        id: "",
                        fields: {
                            Brand: { defaultValue: {id: 1, name: "Ford" }}
                        }
                    }
                }
            },

删除下拉列表中的选项标签:

optionLabel: { id: 0, name: "" },

并强制他们选择一个值