PDA

View Full Version : Can't make working the 'root' property of Ext.util.Sorter to sort a store



mjeulinl
8 Dec 2014, 5:59 AM
Hi,

I am trying to sort my store depending on the following hierarchy "data.lastItem.creation" with data described as follow:
"1: constructor
data: Object1
[...]
lastItem:
creation: 1417530818510

[...]"

My sorter is defined as follow:


store: menuCheckItem.getStore(),
root: menuCheckItem.root, ('data', 'lastItem' or 'data.lastItem')
property: menuCheckItem.property,

I've tried to set the root property to 'lastItem' or event 'data.lastItem', nevertheless I still get the following error:
"
Uncaught TypeError: Cannot read property 'creation' of undefined
Ext.define.defaultSorterFn
"

I don't understand why it can't reach the lastItem structure.

Thank you very much.
Kind Regards,
Michael Jeulin-L.

joel.watson
8 Dec 2014, 4:54 PM
Hi Michael--

Can you provide your store/model config, as well as an example of your data structure? I'm a little fuzzy on what your data looks like and what you're trying to do.

Thanks!

mjeulinl
9 Dec 2014, 1:19 AM
Thank you for your reply.

I am trying to sort my list given the 'creation' field of the 'lastItem' attribute of my data.
Here is how the data looks like:

{
"code":1200,
"messages":["threads ok"],
"count":6,
"content":[ // List of threads
{
"id":1503,
"title":"test",

"users":[{...}, ...}], // list of users
"sender":{...},
"creation":1381156670261,
"itemsCount":2,
"lastItem":{
"id":177,
"content":"...",
"sender":{...},
"children":[...],
"users":[...],
"creation":1381156992999,
},
},
}],
"success":true
}

and the fields of my model:


fields: [
'entityId',
'entityType',
{
name:'attachedComponents',
defaultValue: null
},
'creation',
'id',
'lastItem', // ThreadItem
'private',
'reference',
'sender', // Users
'title',
'users', // Users Array
'itemsCount',
'hasAllComponentUsers',
'rights'
],

Then the cleaner to my mind was to put the root as 'lastItem', howerver it does not work.
Thank you very much.

mjeulinl
15 Dec 2014, 1:25 AM
i wonder then if it isn't a bug from ext? For now I'm using a custom 'sorterFn' and 'elm.data.lastItem.creation' to make it works properly.