PDA

View Full Version : TreeStore sorters ain't working :(



Lemontreestore
26 May 2011, 12:35 PM
Hello everybody, i'm currently facing a trouble and I don't know if it comes from my code or a bug from your library.

Anyway, the thing is that I can't sort properly my TreeStore.

I have 2 items and I want them sorted ascending with the field "text".



items: [{
text: 'McDonald',
distance: 100,
leaf: true
},
{
text: 'KFC',
distance: 120,
leaf: true
}]



So I put a Sorter


sorters:
{

direction: 'ASC',
property: 'text',
root: 'items'

}



What am I doing wrong ?


Best regards.

Thanks.

matheox
27 May 2011, 1:01 AM
I have exactly the same problem...And I don't know how to fix it

thven90
5 Aug 2011, 4:18 AM
Hey there,
it's the same for me, I am also using a TreeStore, but after searching in the internet i didn't find a solution, the only way to fix it seems to be sorting the data before it is loaded into the store.

If it is loaded from a db, order it and if the data is static, order it by yourself ;)

This seems to be the only solution.

elmarburke
8 Aug 2011, 7:46 AM
I have the same problem. It look likes a bug...

matt_d_rat
15 Aug 2011, 1:29 AM
Yep, same problem for me.

nagwww
16 Dec 2011, 4:56 PM
Hi,
Can someone please help. Looks like sorting is not working or we are missing something

Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,
onReady: function() {


var data = {
text: 'Groceries',
items: [{
text: 'Drinks',
items: [{
text: 'Water',
items: [{
text: 'Sparkling',
leaf: true
},{
text: 'Still',
leaf: true
}]
}, {
text: 'Coffee',
leaf: true
}, {
text: 'Espresso',
leaf: true
}, {
text: 'Redbull',
leaf: true
}, {
text: 'Coke',
leaf: true
}, {
text: 'Diet Coke',
leaf: true
}]
},{
text: 'Fruit',
items: [{
text: 'Bananas',
leaf: true
},{
text: 'Lemon',
leaf: true
}]
},{
text: 'Snacks',
items: [{
text: 'Nuts',
leaf: true
},{
text: 'Pretzels',
leaf: true
},{
text: 'Wasabi Peas',
leaf: true
}]
},{
text: 'Empty Category',
items: []
}]
};


Ext.regModel('ListItem', {
fields: [{name: 'text', type: 'string'}]
});


var store = new Ext.data.TreeStore({
model: 'ListItem',
root: data,
sorters: [{ property: 'text', direction: 'ASC'}],
proxy: {
type: 'ajax',
reader: {
type: 'tree',
root: 'items'
}
}
});


var leftNav = new Ext.NestedList({
dock: 'center',
useTitleAsBackText: true,
title: '',
displayField: 'text',
width: '350',
store: store
});


new Ext.Panel({
fullscreen: true,
/* layout: {
type: 'v
box',
align: 'stretch'
},
defaults: {
flex: 1
}, */
dockedItems:[leftNav]
});
}




});



Thanks, Nag