genius551v
1 Aug 2007, 7:47 AM
Hi,
i was a long ~o) ~o) ~o) ~o) month try implementing the toolbar from json and i get that:
(just for your knowledge :) )
code PHP (json):
$tbElements = Array(
Array( //1 firts object to tb
"type" => "menu", //type menu this meaning the object will have items
"config" => Array( //2 just the config to the object
"text" => utf8_encode("Menu"),
"hidden" => false,
"disabled" => false
), //2 end config to the object
"items" => Array( //3 the ITEMS to object
Array(//20 firts Item inside first object
"type" => "menu", //type menu this meaning the object will have items TOO!
"config" => Array(//21 just the config to the object
"text" => utf8_encode("Firts item"),
"hidden" => false,
"disabled" => false,
"hideOnClick" => false
),//21 end config firts Item inside first object
"items" => Array(//22 items to firts item
Array(//23 firts Item (element) inside first item =P~
"type" => "", // this meaning just is a default element to menu
"config" => Array(//24 I believe that she exceeds to explain :-?
"text" => utf8_encode("Firts element to firts item"),
"hidden" => false,
"disabled" => false,
"handler" => "MainViewer.addMenuTree.createDelegate(MainViewer)"
)//24
),//23
Array(//25 second Item (element) inside first item
"type" => "",
"config" => Array(//26
"iconCls" => "",
"text" => utf8_encode("Second element to firts item"),
"hidden" => false,
"disabled" => true
)//26
)//25
)//22
),//20
//End Firts Item inside menu
//other Item inside menu
Array(//27
"type" => "",
"config" => Array(//28
"iconCls" => "",
"text" => utf8_encode("Other more"),
"hidden" => false,
"disabled" => true
)//28
)//27
//End other Item inside menu
)//3 End items de menu inicio
)// 1
//End firts Object to tb
);// end array elements
js code:
// add toolbar elements
addToolbarElements : function(el, tb){
var elements = eval(el);
for(var i=0; i<elements.length; i++){
var element = elements[i];
switch (element.type){
case 'button' : if(element.config['handler']){
element.config['handler'] = eval(element.config['handler']);
}
tb.addButton(element.config);
break;
case 'separator' : tb.addSeparator();
break;
case 'menu' : var menu = new Ext.menu.Menu({items: MainViewer.buildMenus(element)}); //call to build the menus!!!
element.config.menu = menu;
tb.add(element.config);
break;
default : alert('element type: unknow');
} //end switch
} // end for
}, // end function
// add menu elements
buildMenus : function(el){
var items = [];
for(var i=0; i<el.items.length; i++){
var element = el.items[i];
switch (element.type){
case 'CheckItem' : alert('Not yet!'); //just put the code!
break;
case 'ColorItem' : alert('Not yet!'); //just put the code!
break;
case 'separator' : items.push('-');
break;
case 'menu' : var menu = new Ext.menu.Menu({items: MainViewer.buildMenus(element)}); //call RECURSIVE ;-)
element.config.menu = menu;
items.push(element.config);
break;
default : if(element.config['handler']){
element.config['handler'] = eval(element.config['handler']);
}
items.push(element.config);
break;
} //end switch
} //end for
return items;
} // end function
result:
(see the Attachments)
doubts, questions, suggestions...wellcomes
tnks :D
i was a long ~o) ~o) ~o) ~o) month try implementing the toolbar from json and i get that:
(just for your knowledge :) )
code PHP (json):
$tbElements = Array(
Array( //1 firts object to tb
"type" => "menu", //type menu this meaning the object will have items
"config" => Array( //2 just the config to the object
"text" => utf8_encode("Menu"),
"hidden" => false,
"disabled" => false
), //2 end config to the object
"items" => Array( //3 the ITEMS to object
Array(//20 firts Item inside first object
"type" => "menu", //type menu this meaning the object will have items TOO!
"config" => Array(//21 just the config to the object
"text" => utf8_encode("Firts item"),
"hidden" => false,
"disabled" => false,
"hideOnClick" => false
),//21 end config firts Item inside first object
"items" => Array(//22 items to firts item
Array(//23 firts Item (element) inside first item =P~
"type" => "", // this meaning just is a default element to menu
"config" => Array(//24 I believe that she exceeds to explain :-?
"text" => utf8_encode("Firts element to firts item"),
"hidden" => false,
"disabled" => false,
"handler" => "MainViewer.addMenuTree.createDelegate(MainViewer)"
)//24
),//23
Array(//25 second Item (element) inside first item
"type" => "",
"config" => Array(//26
"iconCls" => "",
"text" => utf8_encode("Second element to firts item"),
"hidden" => false,
"disabled" => true
)//26
)//25
)//22
),//20
//End Firts Item inside menu
//other Item inside menu
Array(//27
"type" => "",
"config" => Array(//28
"iconCls" => "",
"text" => utf8_encode("Other more"),
"hidden" => false,
"disabled" => true
)//28
)//27
//End other Item inside menu
)//3 End items de menu inicio
)// 1
//End firts Object to tb
);// end array elements
js code:
// add toolbar elements
addToolbarElements : function(el, tb){
var elements = eval(el);
for(var i=0; i<elements.length; i++){
var element = elements[i];
switch (element.type){
case 'button' : if(element.config['handler']){
element.config['handler'] = eval(element.config['handler']);
}
tb.addButton(element.config);
break;
case 'separator' : tb.addSeparator();
break;
case 'menu' : var menu = new Ext.menu.Menu({items: MainViewer.buildMenus(element)}); //call to build the menus!!!
element.config.menu = menu;
tb.add(element.config);
break;
default : alert('element type: unknow');
} //end switch
} // end for
}, // end function
// add menu elements
buildMenus : function(el){
var items = [];
for(var i=0; i<el.items.length; i++){
var element = el.items[i];
switch (element.type){
case 'CheckItem' : alert('Not yet!'); //just put the code!
break;
case 'ColorItem' : alert('Not yet!'); //just put the code!
break;
case 'separator' : items.push('-');
break;
case 'menu' : var menu = new Ext.menu.Menu({items: MainViewer.buildMenus(element)}); //call RECURSIVE ;-)
element.config.menu = menu;
items.push(element.config);
break;
default : if(element.config['handler']){
element.config['handler'] = eval(element.config['handler']);
}
items.push(element.config);
break;
} //end switch
} //end for
return items;
} // end function
result:
(see the Attachments)
doubts, questions, suggestions...wellcomes
tnks :D