将数据绑定到剑道多选下拉列表时出现问题

时间:2019-05-14 12:45:00

标签: kendo-grid

我有一个角形的剑道网格,应该有一些带有多选下拉菜单的列。

当我第一次从列表中选择该项目时,该项目将被绑定,而第二个项目在被选中时gridParams将保留所选的第二个项目,但是一旦API调用返回数据,该列表便被绑定刷新为无(没有数据绑定到下拉列表)。

下面是与代码相关的

{
    OC.setReportGridColumns(responsecolumns);
        OC.reportsGridOptions = {                    
        dataSource: {
            schema: {
                data: "Data",
                total: "Total",
                model: {
                        fields: OC.GetSchemaFields()
                        }
                    },
                transport: {                            
                        read: function (e) {
                        gridParams = JSON.parse(JSON.stringify({
                            CurrentPage: e.data.page,
                            PageSize: e.data.pageSize,
                            Sort: e.data.sort,
                            Filter: e.data.filter
                            }));
                            if (gridParams.Filter != undefined) {
                                var a;
                                if (gridParams.Filter.filters!= undefined) {                                  
                                    angular.forEach(gridParams.Filter.filters, function (value, key) {
                                    if (value.field === "QuoteStatus") {
                                        value.operator = "in";
                                        a = "'" + value.value + "'";
                                        a = a.replace(",", "','");
                                        value.value = a;
                                    }
                                });
                            };                                
                        };
                        ReportService.GetAllAdHocReport(gridParams, '', OC.CustomColumnSelected, TemplateId).then(function (response) {
                            if (response != '') { 
                                $("li [ui- sref='AdHocReport']").parent().addClass("activelist");
                                response.Total = response.Data != null && response.Data.length > 0 ? response.Data[0].TotalRecords : 10;
                                OC.GridConfigDataSource.read();
                                e.success(response);
                                OC.hideFilters();
                            } else {
                                e.success([]);
                            }  
                    });
                },
            },                   
            filterable: {
                mode: "row,menu",
                extra:false
            },
            selectable: 'cell',                  
            columns: OC.gridCols,
        }       
    }
}

OC.setReportGridColumns = function (colList) {
var col = JSON.parse(colList).columns;
    OC.setfilterDropdown(col);
    var cols = col.map(function (value) {
        if (value.column == "QuoteStatus") {
            return {
                field: value.column,
                title: value.title,
                filterable: OC.filterDropdowns(value.column),
                width: value.width,
                sortable: true,
            };
        }
    }); 
}

OC.filterDropdowns = function (column) {
    return {
        extra: false,
        mode: "menu",
        multi: true,
        cell: {
            showOperators: false,
            template: function (args) {
            /////------****Multi-select Dropdown****------///////
                args.element.kendoMultiSelect({
                    autoBind: true,
                    dataTextField: "text",
                    dataValueField: "value",
                    dataSource: new kendo.data.DataSource({
                        data: OC.getDataForFilterDropdown(column)
                    }),
                    index: 0,
                    optionLabel: {
                        text: "--Select--",
                        value: ""
                    },
                    valuePrimitive: true,
                });
            },
        }
    }
}

0 个答案:

没有答案