Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.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 Grid_Kendo Dropdown - Fatal编程技术网

Kendo ui 剑道下拉列表默认项与剑道网格绑定

Kendo ui 剑道下拉列表默认项与剑道网格绑定,kendo-ui,kendo-grid,kendo-dropdown,Kendo Ui,Kendo Grid,Kendo Dropdown,我想把剑道下拉列表加入我的表格。 一切都会好的,除了一件事。 当我想用默认的剑道创建工具栏“添加记录”时,我不能绑定从dropdownlist数据源获取的第一个值 数据源工作正常。Dropdownlist也很好用。 如果我手动从dropdownlist中选择任何内容,则一切正常 $scope.mainGridOptions = { dataSource: { transport: ...

我想把剑道下拉列表加入我的表格。 一切都会好的,除了一件事。 当我想用默认的剑道创建工具栏“添加记录”时,我不能绑定从dropdownlist数据源获取的第一个值

数据源工作正常。Dropdownlist也很好用。 如果我手动从dropdownlist中选择任何内容,则一切正常

 $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,
                                });
                            }
                    },
                  ...
                ]
            };

有人吗?

所以,我找到了解决办法

这似乎是剑道下拉列表的一个错误

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

我们开始:

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
编辑器:函数(容器、选项){
变量输入=$('');
input.attr('name',options.field);
input.attr('data-bind','value:'+options.field);
输入。附加到(容器);
input.kendoDropDownList({
自动绑定:是的,
dataTextField:“文本”,
dataValueField:“值”,
数据源:locationsDataSource,
索引:0,
数据绑定:函数(){
options.model[options.field]=此.dataItem()值;
}//结束数据绑定
});//结束下拉列表
}//终端编辑器
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