Comister
22 Jul 2012, 12:59 PM
Hi folks,
I currently try to load a tree and i am not sure if i am taking the right approach.
The idea is to load the root elements and/or the elements below root through an ajax proxy into a TreeStore.
I think i already have the load itself working but i am facing issues with mapping my data to a column, because i do not use a associative array, data looks simply like that:
["Value A", "Value B", "Value C"]
The following Code is used to setup the Store, Model and Tree:
The tree:
Ext.define('MyApp.view.wndTest', {
extend: 'Ext.window.Window', height: 539,
id: 'winTest',
width: 349,
title: 'Test',
modal: true,
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'treepanel',
height: 467,
id: 'treeTest',
title: 'Test',
hideHeaders: true,
store: 'MyTestStore',
displayField: 'Name',
folderSort: true,
viewConfig: {
maintainFlex: true,
loadingText: 'Retrieving Data',
multiSelect: true,
simpleSelect: false
},
columns: [
{
xtype: 'gridcolumn',
text: 'Name'
}
]
}
]
});
me.callParent(arguments);
}
});
The Store:
Ext.define('MyApp.store.MyTreeStore', {
extend: 'Ext.data.TreeStore',
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
filterOnLoad: false,
sortOnLoad: false,
storeId: 'MyTreeStore',
defaultRootId: '/',
folderSort: false,
nodeParam: 'path',
root: {
text: 'path',
id: '/',
expanded: true
},
proxy: {
type: 'ajax',
url: '/get-it.php?action=do-it',
reader: {
type: 'json',
root: '/'
}
},
fields: [
{
mapping: 0,
name: 'Name'
}
]
}, cfg)]);
}
});
I tried to map with {0} the index 0 to the column ( also with simple 0 ), seems not to work, is there another way to do so ?
Maybe i need to redesign but i think its a matter of mapping the value to the field because i get empty lines in the view.
Thanks for any hint.
Just forgot, i am using the actual extjs version 4.1.1 !
I currently try to load a tree and i am not sure if i am taking the right approach.
The idea is to load the root elements and/or the elements below root through an ajax proxy into a TreeStore.
I think i already have the load itself working but i am facing issues with mapping my data to a column, because i do not use a associative array, data looks simply like that:
["Value A", "Value B", "Value C"]
The following Code is used to setup the Store, Model and Tree:
The tree:
Ext.define('MyApp.view.wndTest', {
extend: 'Ext.window.Window', height: 539,
id: 'winTest',
width: 349,
title: 'Test',
modal: true,
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'treepanel',
height: 467,
id: 'treeTest',
title: 'Test',
hideHeaders: true,
store: 'MyTestStore',
displayField: 'Name',
folderSort: true,
viewConfig: {
maintainFlex: true,
loadingText: 'Retrieving Data',
multiSelect: true,
simpleSelect: false
},
columns: [
{
xtype: 'gridcolumn',
text: 'Name'
}
]
}
]
});
me.callParent(arguments);
}
});
The Store:
Ext.define('MyApp.store.MyTreeStore', {
extend: 'Ext.data.TreeStore',
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
filterOnLoad: false,
sortOnLoad: false,
storeId: 'MyTreeStore',
defaultRootId: '/',
folderSort: false,
nodeParam: 'path',
root: {
text: 'path',
id: '/',
expanded: true
},
proxy: {
type: 'ajax',
url: '/get-it.php?action=do-it',
reader: {
type: 'json',
root: '/'
}
},
fields: [
{
mapping: 0,
name: 'Name'
}
]
}, cfg)]);
}
});
I tried to map with {0} the index 0 to the column ( also with simple 0 ), seems not to work, is there another way to do so ?
Maybe i need to redesign but i think its a matter of mapping the value to the field because i get empty lines in the view.
Thanks for any hint.
Just forgot, i am using the actual extjs version 4.1.1 !