Rally App SDK 2.0rc1-为什么我的组合框只在第一次点击时忽略数据存储过滤器

Rally App SDK 2.0rc1 - Why does my combobox ignore datastore filters only on first click?

本文关键字:第一次 过滤器 存储 数据 SDK App 0rc1- 为什么 组合 我的 Rally      更新时间:2024-05-28

我有以下代码(草率,我知道…第一个javascript应用程序)。我正试图让一个组合框填充一个给定版本下的功能列表(在第一个组合框中选择)。现在几乎所有功能都正常工作,除了每次我第一次单击功能组合框时,它都会加载所有功能并完全忽略过滤器。即使我首先更改了发布框,功能框仍然只在第一次单击时填充所有功能。随后,它将显示正确过滤的特征。

更奇怪的是,我已经尝试将FeatureStore中的总记录写入控制台,这样我就可以看到这种情况何时发生。当功能组合框第一次创建时,它有正确数量的记录。然而,当我第一次点击功能组合框时,它会触发组合框的"加载"监听器,并拉入所有功能,完全忽略过滤器。

我很困惑,我已经尝试了很多方法来调试它,但目前没有其他选择。有人知道为什么它会先加载正确的数据,然后重新加载,并在第一次点击时忽略过滤器吗?

Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
    var relComboBox = Ext.create("Rally.ui.combobox.ReleaseComboBox", {
        fieldLabel: 'Choose a Release',
        width: 300,
        listeners: {
            ready: function(combobox) {
                this._releaseRef = combobox.getRecord().get("_ref");
                this._loadFeatureInfo();
            },
            select: function(combobox) {
                this._releaseRef = combobox.getRecord().get("_ref");
                this._loadFeatureInfo();
            },
            scope: this
        }
    });
    this.add(relComboBox);
},
_loadFeatureInfo: function() {
    var featureStore = Ext.create("Rally.data.WsapiDataStore", {
        model: "portfolioitem/Feature",
        fetch: ["Name", "_ref"],
        autoLoad: true,
        filters: [
            {
                property: "Release",
                operator: "=",
                value: this._releaseRef
            }
        ],
        listeners: {
            load: function(store) {
                this._updateFeatureBox(store);
            },
            scope: this
        }
    });
},
_createFeatureBox: function(featureStore) {
    this._featureComboBox = Ext.create("Rally.ui.combobox.ComboBox", {
        fieldLabel: 'Choose a Feature to move',
        store: featureStore,
        listeners: {
            select: function (combobox) {
                this._featureRef = combobox.getRecord().get("_ref");
                //calls method to get and display children of this feature in a grid
            },
            scope: this
        }
    });
    this.add(this._featureComboBox);
},
_updateFeatureBox: function(featureStore) {
    if (this._featureComboBox === undefined) {
        this._createFeatureBox(featureStore);
    } else {
        this._featureComboBox.clearValue();
        this._featureComboBox.bindStore(featureStore);
        //calls method to get and display children of this feature in a grid
    }
}

这可能是由于featureStore加载两次引起的问题:一次是在创建时,而组合框还告诉在用户打开组合框选择功能后再次加载。

我在Stories上遇到了一个非常类似的组合框问题,我敢打赌Matt Greer的答案是:

Rally.ui.combobox.combobox 的奇怪负载行为

对于我的问题,你的答案也是。。。