PDA

View Full Version : ExtJS4 treegrid - list leafs before nodes



rapideye
16 Aug 2013, 2:30 PM
Hi,
I have a simple question... I couldn't find anything in the docs that mentioned how to do this. But how would I configure the treegrid if I would like it to list all the leafs first, then all the nodes? The default is listing all the nodes first, and then the leafs, but in my case it makes more sense to do this the other way around. Is there a simple way to do this? Thanks!

scottmartin
16 Aug 2013, 7:50 PM
Can you clarify this?

rapideye
20 Aug 2013, 9:37 AM
Currently, in my tree panel, the results are displayed something like this:

node
node
- node
- node
- leaf
leaf
leaf

I would like them displayed something like this

leaf
leaf
node
node
- leaf
- node
- node

Is this possible?

EDIT

I should probably include my config.


var userStore = Ext.create('Ext.data.TreeStore', {
folderSort: true,
nodeParam: 'id',
id: 'userStore',
autoLoad: false,
proxy: {
type: 'ajax',
url: USER_DATA_URL,
reader: {
type: 'json',
root: 'data',
idProperty: 'id'
}
},
fields:['user_name', 'email','id', 'leaf', 'expanded', 'group_id']
});

var tree = Ext.create('Ext.tree.Panel', {
title: 'Manage Users',
animate: true,
id: 'userGrid',
height: 500,
renderTo: 'userPanel',
rootVisible: false,
store: userStore,
folderSort: false,
multiSelect: false,
columns: [{
xtype: 'treecolumn',
text: 'Username',
width: 250,
sortable: true,
dataIndex: 'user_name',
locked: true
},{......}]
}

rapideye
20 Aug 2013, 1:28 PM
Just as I was posting the update with my code, I realized that in my store I have 'folderSort: true'. That is where the problem is... setting it to false gives me the results that I want. I didn't realize that I had defined that property in both the store AND the tree panel. Rookie mistake...

Thanks