CA Agile Central如何开启过滤功能?

How Do I Enable Filter Functions in CA Agile Central?

我需要使用过滤器函数来实现用于选择记录的启发式方法。仅靠简单的 field/value 检查不足以达到我们的目的。

我正在尝试按照函数过滤器的示例进行操作,但由于某种原因,"allowFunctions" 标志一直设置为 false。

我尝试在 storeConfig 中将 allowFunctions 属性 设置为 true:

            storeConfig: {
                models: ['userstory', 'defect'], 
                allowFunctions: true,                   
                filters: [{
                    // This did not work ...
                    property: 'Iteration.Name',
                    value: 'Sprint 3',
                    // Trying dynamic Filter Function.  Update: Never called.
                    filterFn: function (item) {
                        console.log("Entered Filter Function!");
                        var iter = item.get("Iteration");
                        console.log("Iteration field: ", iter);
                        if (iter !== null && iter !== undefined) {
                            return (iter.name === "Sprint 3");
                        } else {
                            return false;
                        }
                    }
                }]
            },

网格视图呈现后,我检查了商店配置及其过滤器:

            listeners: {
                afterrender: {
                    fn: function (_myVar, eOpts) {
                        console.log("Arg to afterrender: ", _myVar, " and ", eOpts);
                        var _myStore = _myVar.getStore();
                        console.log("Store filters: ", _myStore.filters);
                    }
                }
            },

我发现 allowFunctions 属性 已设置回 false,我发现我指定的过滤器函数从未触发。

Console Screen Shot

所以要么我在错误的地方将 allowFunctions 设置为 true,要么 Rally Grid View 及其数据存储中内置的东西禁止过滤功能并将标志翻转回 false。

或者还有第三种选择表明我的操作理论有多么糟糕。

呵呵,各位前辈请指教

这是整个 Apps.js 文件:

Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',
    launch: function () {
        //Write app code here
        console.log("Overall App Launch function entered");
        //API Docs: https://help.rallydev.com/apps/2.1/doc/
    }
});

Rally.onReady(function () {
    Ext.define('BOA.AdoptedWork.MultiArtifactGrid', {
        extend: 'Rally.app.App',
        componentCls: 'app',

        launch: function () {
            console.log("onReady Launch function entered");
            this.theGrid = {
                xtype: 'rallygrid',
                showPagingToolbar: true,
                showRowActionsColumn: false,
                editable: false,
                columnCfgs: [
                    'FormattedID',
                    'Name',
                    'ScheduleState',
                    'Iteration',
                    'Release',
                    'PlanEstimate',
                    'TaskEstimateTotal',
                    'TaskActualTotal', // For some reason this does not display ?? :o( ??
                    'TaskRemainingTotal'
                ],
                listeners: {
                    afterrender: {
                        fn: function (_myVar, eOpts) {
                            console.log("Arg to afterrender: ", _myVar, " and ", eOpts);
                            var _myStore = _myVar.getStore();
                            console.log("Store filters: ", _myStore.filters);
                        }
                    }
                },
                storeConfig: {
                    models: ['userstory', 'defect'], 
                    allowFunctions: true,                   
                    filters: [{
                        // This did not work ...
                        property: 'Iteration.Name',
                        value: 'Sprint 3',
                        // Trying dynamic Filter Function.  Update: Never called.
                        filterFn: function (item) {
                            console.log("Entered Filter Function!");
                            var iter = item.get("Iteration");
                            console.log("Iteration field: ", iter);
                            if (iter !== null && iter !== undefined) {
                                return (iter.name === "Sprint 3");
                            } else {
                                return false;
                            }
                        }
                    }]
                },
                context: this.getContext(),
                scope: this
            };
            this.add(this.theGrid);
            console.log("The Grid Object: ", this.theGrid);
        }
    });


    Rally.launchApp('BOA.AdoptedWork.MultiArtifactGrid', {
        name: 'Multi-type Grid'
    });
});

这是一个棘手的问题,因为您仍然希望应用服务器过滤器,然后您希望在客户端进一步过滤数据。

在此处查看此示例: https://github.com/RallyCommunity/CustomChart/blob/master/Settings.js#L98

我认为您基本上可以向您的商店添加一个负载侦听器,然后在该处理程序中您可以执行 filterBy 以在客户端进一步过滤您的结果。

listeners: {
    load: function(store) {
        store.filterBy(function(record) {
            //return true to include record in store data
        });
    }
}

我不熟悉 allowFunctions,但一般来说,remoteFilter: true/false 控制过滤是发生在服务器端还是客户端。 remoteFilter: true + 上面的负载处理程序为您提供了两全其美的方法。