varunjyoti
3 Jul 2012, 3:34 AM
I have a Tree Panel
Ext.define('DG.view.reports.AttributeFilter', {
extend: 'Ext.tree.Panel',
alias: 'widget.AttributeFilter',
store:'Attributes'
});
and a TreeStore
Ext.define('DG.store.Attributes', {
extend: 'Ext.data.TreeStore',
model: 'DG.model.Attribute',
listeners: {
append: function( thisNode, newChildNode, index, eOpts ) {
if( !newChildNode.isRoot() ) {
newChildNode.set('leaf', true);
newChildNode.set('checked', true);
newChildNode.set('text', newChildNode.get('attributeName'));
}
}
} ,
proxy: {
type: 'ajax',
url: 'http://localhost:8080/DgDashboard/app/Attributes.json',
reader: {
type: 'json',
root: 'result',
successProperty: 'success'
}
},
});
The JSON retruned is
{
"success":true,
"result":[
{
"attributeId":"1",
"attributeType":"Application",
"attributeName":"Application1",
"attributeDesc":"Application"
},
{
"attributeId":"2",
"attributeType":"LOB",
"attributeName":"LOB1",
"attributeDesc":"LOB"
},
{
"attributeId":"3",
"attributeType":"LOB",
"attributeName":"LOB2",
"attributeDesc":"LOB"
}
]
}
Currently the tree panel is showing data as
Root
-->Application1
-->LOB1
-->LOB2
I want to group the data based on "attributeType". So the data should be displayed as
Root
-->Application
-->Application1
-->LOB
-->LOB1
-->LOB2
Is there an inbuilt way to do it easily, or i have to write a logic to add nodes one by one based on their type etc.
Ext.define('DG.view.reports.AttributeFilter', {
extend: 'Ext.tree.Panel',
alias: 'widget.AttributeFilter',
store:'Attributes'
});
and a TreeStore
Ext.define('DG.store.Attributes', {
extend: 'Ext.data.TreeStore',
model: 'DG.model.Attribute',
listeners: {
append: function( thisNode, newChildNode, index, eOpts ) {
if( !newChildNode.isRoot() ) {
newChildNode.set('leaf', true);
newChildNode.set('checked', true);
newChildNode.set('text', newChildNode.get('attributeName'));
}
}
} ,
proxy: {
type: 'ajax',
url: 'http://localhost:8080/DgDashboard/app/Attributes.json',
reader: {
type: 'json',
root: 'result',
successProperty: 'success'
}
},
});
The JSON retruned is
{
"success":true,
"result":[
{
"attributeId":"1",
"attributeType":"Application",
"attributeName":"Application1",
"attributeDesc":"Application"
},
{
"attributeId":"2",
"attributeType":"LOB",
"attributeName":"LOB1",
"attributeDesc":"LOB"
},
{
"attributeId":"3",
"attributeType":"LOB",
"attributeName":"LOB2",
"attributeDesc":"LOB"
}
]
}
Currently the tree panel is showing data as
Root
-->Application1
-->LOB1
-->LOB2
I want to group the data based on "attributeType". So the data should be displayed as
Root
-->Application
-->Application1
-->LOB
-->LOB1
-->LOB2
Is there an inbuilt way to do it easily, or i have to write a logic to add nodes one by one based on their type etc.