如何按父母故事的格式化ID对用户故事网格进行排序

时间:2013-07-24 18:27:53

标签: rally

我尝试将分拣机添加到Rally.data.WsapiDataStore,但它无法正常工作。 是否可以按父母的字段排序?

Ext.create('Rally.data.WsapiDataStore', {
            model: 'UserStory',
            fetch: ['FormattedID','Name','HasParent','Parent'],
            pageSize: 100,
            autoLoad: true,
        sorters: [
            {
            property: 'Parent.FormattedID',
            direction: 'DESC'
            }
            ],
            listeners: {
                load: this._onDataLoaded,
                scope: this
            }
        });

另外,我尝试按“HasParent”进行过滤,但它也没有用。

filters: [
            {
            property: 'HasParent',
            operator: '=',
            value: true
            }
]

谢谢!

2 个答案:

答案 0 :(得分:0)

以下是一个示例,其中网格按父级故事的FormattedID排序。分拣机被添加到Rally.data.custom.Store,而不是Rally.data.WsapiDataStore

    <!DOCTYPE html>
<html>
<head>
    <title>TCofUS</title>

    <script type="text/javascript" src="/apps/2.0rc1/sdk.js"></script>



    <script type="text/javascript">
        Rally.onReady(function () {
Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',

    launch: function() {
        Ext.create('Rally.data.WsapiDataStore', {
            model: 'UserStory',
            fetch: ['FormattedID','Name','HasParent','Parent'],
            pageSize: 100,
            autoLoad: true,
            listeners: {
                load: this._onDataLoaded,
                scope: this
            }
        });
    },

    _createGrid: function(stories) {
         this.add({
            xtype: 'rallygrid',
            store: Ext.create('Rally.data.custom.Store', {
                data: stories,
                pageSize: 100,
                 sorters: [
            {
            property: 'Parent',
            direction: 'DESC'
            }
            ],
            }),
            columnCfgs: [
                {
                   text: 'Formatted ID', dataIndex: 'FormattedID', xtype: 'templatecolumn',
                    tpl: Ext.create('Rally.ui.renderer.template.FormattedIDTemplate')
                },
                {
                    text: 'Name', dataIndex: 'Name'
                },
                {
                    text: 'Parent', dataIndex: 'Parent',
                   renderer: function(parent) {
                        return ('<a href="' + Rally.nav.Manager.getDetailUrl(parent) + '">' + parent + '</a>');
                   }
                }
            ]

        });
    },
    _onDataLoaded: function(store, data){
                var stories = [];
                Ext.Array.each(data, function(story) {
                            var parent = story.get('Parent');
                            var s  = {
                                FormattedID: story.get('FormattedID'),
                                Name: story.get('Name'),
                                _ref: story.get("_ref"),
                                 Parent: (parent && parent.FormattedID) || 'None',
                            };
                            stories.push(s);
                },
                this);
                 this._createGrid(stories);
    }             
});


            Rally.launchApp('CustomApp', {
                name:"TCofUS",
                //parentRepos:""
            });

        });
    </script>


    <style type="text/css">
.app {
     /* Add app styles here */
}

    </style>

</head>
<body></body>
</html>

就过滤器而言,每个WS API documentation HasParent不能用于查询。 上面的代码检查父母的伪装,如果没有父母,则打印“无”:

 Parent: (parent && parent.FormattedID) || 'None'

答案 1 :(得分:0)

使用过滤器的另一种方法是简单地过滤Parent!=''

filters: [
{
    property: 'Parent',
    operator: '!=',
    value: ''
}