【问题标题】:Kendo DropDownList default item binding with Kendo GridKendo DropDownList 默认项与 Kendo Grid 绑定
【发布时间】:2015-05-10 07:48:17
【问题描述】:

我想将剑道下拉列表包含在我的网格中。 一切都会好起来的,除了一件事。 当我想使用默认剑道创建工具栏“添加记录”时,我无法绑定从下拉列表数据源中获取的第一个值。

数据源工作正常。下拉列表也可以正常工作。 如果我手动从下拉列表中选择任何内容,一切正常。

 $scope.mainGridOptions = {

                dataSource: {
                    transport: ...
                    schema: ...
                },

                batch: false,
                       ...    
                toolbar: ["create"],
                columns: [
                    ...,{

                    field: "location_id",
                    title: "Location",

                    editor: function(container,options){

                                var input = $('<input/>');
                                input.attr('name',options.field);
                                input.appendTo(container);

                                input.kendoDropDownList({
                                    autoBind: true,
                                    dataTextField: "text",
                                    dataValueField: "value",
                                    dataSource: locationsDataSource,
                                    index: 0,
                                });
                            }
                    },
                  ...
                ]
            };

我也试过这个。除了“索引”,我尝试从数据源中手动选择第一项。视觉上它工作正常。即使选择了第三项,但是当我单击“更新”时,数据没有限制。

input.kendoDropDownList({
     autoBind: true,
     dataTextField: "text",
     dataValueField: "value",
     dataSource: locationsDataSource,
     dataBound: function(e){
        this.select(0);
     }
});

有人吗?

【问题讨论】:

    标签: kendo-ui kendo-grid kendo-dropdown


    【解决方案1】:

    所以,我找到了解决方案。

    好像是Kendo DropDownList的bug。

    我在从下拉数据绑定事件加载数据源后手动绑定它。

    我们开始吧:

    editor: function(container,options){
    
            var input = $('<input/>');
            input.attr('name',options.field);
            input.attr('data-bind','value:' + options.field);
            input.appendTo(container);
    
            input.kendoDropDownList({
                autoBind: true,
                dataTextField: "text",
                dataValueField: "value",
                dataSource: locationsDataSource,
                index: 0,
                dataBound: function(){
    
                    options.model[options.field] = this.dataItem().value;
    
                }//end databound
    
            });//end dropdownlist
    
    }//end editor
    

    【讨论】:

      猜你喜欢
      • 2017-12-25
      • 2014-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-09
      • 1970-01-01
      • 2018-03-17
      相关资源
      最近更新 更多