0

I tried to add a sorter to a Rally.data.WsapiDataStore and it did not work. Is it possible to sort by a parent's field?

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

Also, I tried to filter by "HasParent", and it did not work either.

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

Thanks!

4

2 回答 2

0

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

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

]

于 2013-10-16T00:35:55.443 回答
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 文档 HasParent 不能在查询中使用。上面的代码检查父母的伪装,如果没有父母,则打印“无”:

 Parent: (parent && parent.FormattedID) || 'None'
于 2013-07-24T18:36:39.100 回答