Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kendo ui 无法从剑道组合框中获取值_Kendo Ui_Kendo Combobox - Fatal编程技术网

Kendo ui 无法从剑道组合框中获取值

Kendo ui 无法从剑道组合框中获取值,kendo-ui,kendo-combobox,Kendo Ui,Kendo Combobox,我正在剑道网格编辑器中使用下面的代码,但无法从Combobox访问所选项目值的值 此外,我在剑道下拉列表中也做了同样的事情,但无法创建剑道组合框,所以如果有人有解决方案,请告诉我 提前谢谢 { field: "SalesBookId", title: "Sales Book", template: "#= (typeof SalesBookId != 'undefined')

我正在剑道网格编辑器中使用下面的代码,但无法从Combobox访问所选项目值的值

此外,我在剑道下拉列表中也做了同样的事情,但无法创建剑道组合框,所以如果有人有解决方案,请告诉我

提前谢谢

{
                    field: "SalesBookId",
                    title: "Sales Book",
                    template: "#= (typeof SalesBookId != 'undefined') ? GetSalesBookName(SalesBookId):'' #",
                    editor: function (container, options) {

                        $('<input required data-text-field="SalesBookName" data-value-field="SalesBookId" data-bind="value:' + options.field + '"/>')
                            .appendTo(container)
                            .kendoComboBox({
                                autoBind: false,
                                dataSource: dsSalesBookDropDown,

                            });
                    }
                },
{
字段:“SalesBookId”,
标题:“销售手册”,
模板:“#=(typeof SalesBookId!=‘未定义’)?GetSalesBookName(SalesBookId):”“#”,
编辑器:函数(容器、选项){
$('')
.appendTo(容器)
kendoComboBox先生({
自动绑定:错误,
数据源:DSSalesBook下拉列表,
});
}
},

您没有显示
dsSalesBook下拉列表
,也没有显示
GetSalesBookName
,因此很难知道您的具体案例中出现了什么问题

这表明,当配置、处理程序和数据都正确对齐时,应该不会出现问题

dojo是一个基于示例“带有本地数据的网格”的应用程序,您的SalesBook概念更改为Seller作为示例

与自定义编辑器相关的代码包括

var sellers = [
  { SellerId: 1, Name: "Andrew" },
  { SellerId: 2, Name: "Basil" },
  { SellerId: 3, Name: "Chuck" },
  { SellerId: 4, Name: "Dennis" },
  { SellerId: 5, Name: "Edward" }
  ];

var dsSellersDropDown = sellers;    

function GetSellerName (id) {
  var seller = sellers.find(function(x) {return x.SellerId == id });
  return (seller) ? seller.Name : "** invalid id " + id + " **";
}

var products = [{
    ProductID : 1,
    ProductName : "Chai",
SellerId: 1,
    SupplierID : 1,
    CategoryID : 1,
. . .
网格配置

                        dataSource: {
                            data: products,
                            schema: {
                                model: {
                                    fields: {
                                        ProductName: { type: "string" },
SellerId: { type: "number" },

列:[
“产品名称”,
{字段:“SellerId”,
标题:“卖方名称”,
模板:“#=(typeof SellerId!=‘未定义’)?GetSellerName(SellerId):”,
编辑器:函数(容器、选项){
$('')
.appendTo(容器)
kendoComboBox先生({
自动绑定:错误,
数据源:dsSellersDropDown,
});
}
},
{字段:“单价”,标题:“单价”,格式:“{0:c}”,宽度:“130px”},

在您的回复帮助下,我已经解决了我的问题。我刚刚将模式添加到我的网格中,工作正常。您帮了我很大的忙。
                        columns: [
                            "ProductName",
{ field: "SellerId",
  title: "Seller Name",
  template: "#= (typeof SellerId != 'undefined') ? GetSellerName(SellerId):'' #",
  editor: function (container, options) {

    $('<input required data-text-field="Name" data-value-field="SellerId" data-bind="value:' 
+
options.field
+ '"/>')
    .appendTo(container)
    .kendoComboBox({
        autoBind: false,
        dataSource: dsSellersDropDown,
     });
  }
},
                        { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "130px" },