Kendo网格自定义编辑器下拉列表/组合框填充[object.object] [英] Kendo grid custom editor dropdownlist / combobox populates with [object.object]

查看:119
本文介绍了Kendo网格自定义编辑器下拉列表/组合框填充[object.object]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

旁注:人们可以在哪里发布内容以便以后人们可以将其谷歌?



因此,当尝试使用a填充kendo网格中的字段时使用kendo组合框或类似的自定义编辑器,编辑器dorpdown工作正常,但是一旦离开编辑器(离开字段),它就用 [Object.object] 填充输入。这是遵循kendo示例的字母!



在这个问题中,我将从kendo页面发布代码 Kendo UI Grid的配置,方法和事件 [ ^ ]



我尝试过:



A side note: Where does one post something just so people can google it in future?

So when trying to populate a field in a kendo grid using a custom editor with a kendo combobox or similar, the editor dorpdown works fine but as soon as you leave the editor (leave the field) it populates the input with [Object.object]. This is following the kendo example to the letter!

In this question I will post the code from the kendo page Configuration, methods and events of Kendo UI Grid[^]

What I have tried:

$("#grid").kendoGrid({
  columns: [ {
    field: "name",
    editor: function(container, options) {
     // create an input element
     var input = $("<input/>");
     // set its name to the field to which the column is bound ('name' in this case)
     input.attr("name", options.field);
     // append it to the container
     input.appendTo(container);
     // initialize a Kendo UI AutoComplete
     input.kendoAutoComplete({
       dataTextField: "name",
       dataSource: [
         { name: "Jane Doe" },
         { name: "John Doe" }
       ]
     });
    }
  } ],
  editable: true,
  dataSource: [ { name: "Jane Doe" }, { name: "John Doe" } ]
});

推荐答案

#grid)。kendoGrid({
columns:[{
field: name
editor: function (容器,选项){
// 创建输入元素
< span class =code-keyword> var input =
("#grid").kendoGrid({ columns: [ { field: "name", editor: function(container, options) { // create an input element var input =


< input />);
// 将其名称设置为场列绑定到的列(在本例中为name)
input.attr( name,options.field);
// 将其附加到容器
input.appendTo(container);
// 初始化Kendo UI自动完成
input.kendoAutoComplete({
dataTextField: name
dataSource:[
{name: Jane Doe},
{name: John Doe}
]
});
}
}],
可编辑: true
dataSource:[{name: Jane Doe},{name: John Doe}]
});
("<input/>"); // set its name to the field to which the column is bound ('name' in this case) input.attr("name", options.field); // append it to the container input.appendTo(container); // initialize a Kendo UI AutoComplete input.kendoAutoComplete({ dataTextField: "name", dataSource: [ { name: "Jane Doe" }, { name: "John Doe" } ] }); } } ], editable: true, dataSource: [ { name: "Jane Doe" }, { name: "John Doe" } ] });


解决方案是忽略该示例并使用他们有验证的例子。只需添加一些额外的属性即可解决问题(我不知道为什么)



The solution is to ignore that example and use the example they have for validation. Simply adding a couple of extra attributes solves the issue (I have no idea why)

editor: function (container, options) {
	// create an input element
	var input =


这篇关于Kendo网格自定义编辑器下拉列表/组合框填充[object.object]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆