【问题标题】:Not able to get value from the Kendo Combobox无法从 Kendo Combobox 中获得价值
【发布时间】:2018-06-02 12:01:56
【问题描述】:

我在 Kendo Grid 编辑器中使用以下代码,但无法从 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,

                            });
                    }
                },

【问题讨论】:

    标签: kendo-ui kendo-combobox


    【解决方案1】:

    您没有显示dsSalesBookDropDown,也没有显示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" },
    

                            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" },
    

    【讨论】:

    • 在您的回复的帮助下,我已经解决了我的问题。我刚刚将模式添加到我的网格中并且工作正常。你太有帮助了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-24
    • 1970-01-01
    • 2015-11-13
    • 1970-01-01
    • 1970-01-01
    • 2017-05-06
    相关资源
    最近更新 更多