Commit 9f5bb181 authored by legac's avatar legac Committed by LE GAC Renaud
Browse files

Field cfg in now properly defined in the TreeStore.

parent 3c43bd56
""" the ``Node`` class to build navigation tree.
"""
import json
import locale
from gluon import current
......@@ -38,7 +39,7 @@ class Node(object):
the widget associated to the leaf
"""
di = {'cfg': cfg, 'leaf': True, 'text': text}
di = {'cfg': json.dumps(cfg), 'leaf': True, 'text': text}
self.children.append(di)
def add_children(self, leaves, func=None, hidden=[]):
......
......@@ -81,7 +81,15 @@ Ext.define('Dbui.container.Viewport', {
Ext.apply(me, config);
// the TreeStore configuration
// contains the field cfg in addition to the tree node fields
treeStoreCfg = {
fields: [{
name: 'cfg',
type: 'string',
convert: function (value) {
return Ext.JSON.decode(value);
}
}],
root: {
expanded: true,
children: Dbui.config.treeNodes,
......@@ -225,7 +233,7 @@ Ext.define('Dbui.container.Viewport', {
// Create or activate the tab for a leafs
// configuration of the embedded widget
wdgcfg = record.raw.cfg;
wdgcfg = record.get('cfg');
wdgtype = wdgcfg.xtype;
// standalone window
......
/**
* treepanel.js
*
*/
// Activate the dynamic loading for Ext JS and application classes
App.setDynamicLoading(App.debug);
// classes required by the script
Ext.require('Ext.tip.QuickTipManager');
Ext.require('Ext.tree.Panel');
Ext.onReady(function(){
"use strict";
var treepanel,
store;
Ext.QuickTips.init();
store = Ext.create('Ext.data.TreeStore', {
fields: [{name: 'cfg', type: 'string'}],
root: {
text: 'Root',
expanded: true,
children: [
{
cfg: 'foo',
text: 'Child 1',
leaf: true
},
{
text: 'Child 2',
leaf: true
},
{
text: 'Child 3',
expanded: true,
children: [
{
text: 'Grandchild',
leaf: true
}
]
}
]
}
});
treepanel = Ext.create('Ext.tree.Panel', {
renderTo: Ext.getBody(),
title: 'Simple Tree',
width: 300,
height: 250,
useArrows: true,
store: store
});
treepanel.on('itemclick', function (me, record, item, index) {
console.log("hello");
console.log(record.get("cfg"));
});
});
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment