当我更改dxGrid查找数据源时,查找将停止扩展

时间:2019-12-24 10:37:16

标签: typescript mvvm devexpress frontend devextreme

所以我的函数似乎可以处理我的数据,但是此后查找停止工作。 就像当我单击该列使其停止工作时,这是破坏它的代码: (控制台日志之间的线)

console.log("Gender Updating:", $("#EntitlementRules").dxDataGrid("instance").columnOption("GenderID", "lookup"));
$("#EntitlementRules").dxDataGrid("instance").columnOption("GenderID", "lookup.dataSource", distinctGenders);
console.log("Gender Updated:", $("#EntitlementRules").dxDataGrid("instance").columnOption("GenderID", "lookup"));

这是我定义查找的实际列的地方:

                   {
                        dataField: "GenderID",
                        caption: "Gender",
                        allowEditing: true,
                        allowFixing: true,
                        lookup: {
                            dataSource(options) {
                                return {
                                    store: new DevExpress.data.ArrayStore({
                                        data: self.Cache.AllProducts,
                                        key: "ID"
                                    }),
                                }
                            },
                            valueExpr: "GenderTypeCode",
                            displayExpr: "Gender"

                        },
                    },

这是我调用函数的地方

onCellClick: function (e) {self.refreshProductsInRangeGenderandSize(e.data)},

1 个答案:

答案 0 :(得分:0)

我认为dataSource是在数据准备好之前填充的,因此我将该函数放置在2500 ms的JQuery延迟内,以确保数据准备就绪

setTimeout(
function () {
$("#EntitlementRules").dxDataGrid("instance").columnOption("GenderID", "lookup.dataSource", distinctGenders);
$("#EntitlementRules").dxDataGrid("instance").columnOption("SizeID", "lookup.dataSource", distinctSizes);
$("#EntitlementRules").dxDataGrid("instance").columnOption("StyleID", "lookup.dataSource", distinctStyles);
$("#EntitlementRules").dxDataGrid("instance").columnOption("ColourID", "lookup.dataSource", distinctColours);
}, 2500);