Rally SDK 2 custom sorters

How do I get a more complex view in a query I have this query currently:

    var store = Ext.create('Rally.data.custom.Store',{
        data: changes,
        limit: 'Infinity',
        pageSize: 5000,
        sorters: [
            { 
                property: 'ReleaseScope',
                direction: 'ASC'
            },
            {
                property: 'ScheduleState',
                direction: 'DESC'
            }
        ]

    });

      

Since the ScheduleState is hydrated I cannot sort by normal numbers, can I determine the order using some kind of match?

i.e. let's say I want to show in order [Accepted, Done, Done, Determined, Backlog] And if I wanted to complicate this further and show stories with plot points first, something like

All stories with a story point value != 0
    Sorted by schedulestate [accepted, completed, in-progress, defined  etc..]
stories with no story point value
    some other sort here possibly

      

+3


source to share


1 answer


You can pass sorterFn instead of the property / direction command to implement custom sorting logic:

sorters: [
    {
        sorterFn: function(a, b) {
            var scheduleStates = ['Accepted', 'Completed', 'In-Progress', 'Defined'],
            aState = a.get('ScheduleState'),
            aIndex = _.indexOf(scheduleStates, aState),
            bState = b.get('ScheduleState'),
            bIndex = _.indexOf(scheduleStates, bState);
            return a - b;
        }
    }
]

      



The above function should sort them based on the state of the schedule I'm thinking of.

+2


source







All Articles