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

When I change dxGrid lookup dataSource the lookup stops expanding

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

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

我相信数据源在数据准备好之前就已填充,因此我将该函数置于 JQuery 延迟 2500 毫秒以确保数据准备就绪

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);