Find code here before you post.


Postby linb » Sat Apr 27, 2013 3:26 am

// The default code is a com class (inherited from xui.Com)
Class('App.xui_UI_TreeView', 'xui.Com',{
// Ensure that all the value of "key/value pair" does not refer to external variables
// To initialize instance(e.g. properties)
initialize : function(){
this.autoDestroy = true;
// To initialize internal components (mostly UI controls)
// *** If you're not a skilled, dont modify this function manually ***
iniComponents : function(){
// [[code created by CrossUI RAD Tools
var host=this, children=[], append=function(child){children.push(child.get(0))};

(new xui.UI.Panel)
.setCaption("TreeView Demo")

(new xui.UI.TreeView)
.setItems([{"id":"folder1", "caption":"folder1", "image":"img/App.gif", "imagePos":"-32px -32px", "sub":true}, {"id":"folder2", "caption":"folder2", "sub":true}, {"id":"file1", "caption":"file1"}])

return children;
// ]]code created by CrossUI RAD Tools
// Give a chance to load other com
iniExComs : function(com, threadid){
// Give a chance to determine which UI controls will be appended to parent container
customAppend : function(parent, subId, left, top){
// "return false" will cause all the internal UI controls will be added to the parent panel
return false;
// This instance's events
events : {},
_ctl_treeview1_ongetcontent : function (profile, item, callback) {
var ns = this,
uictrl = profile.boxing();
var id=item.id,tid="temp"+_();

// to simulate asyn ajax loading
// remove first
var items=[];
// two files
items.push({id:'file_'+_.id(), caption:'file_'+_.id(),image:"img/App.gif", imagePos:"-80px -48px"});
items.push({id:'file_'+_.id(), caption:'file_'+_.id(),image:"img/App.gif", imagePos:"-16px -48px"});
// a folder
items.push({id:id+'_1', caption:id+'_1', sub:true});
items.push({id:id+'_2', caption:id+'_2', sub:true, image:"img/App.gif", imagePos:"-32px -48px"});
items.push({id:id+'_3', caption:id+'_3', sub:true});
// add new sub items
uictrl.insertItems(items, id);

// for showing loading icon
return [{id:tid, caption:"Loading...", image:xui.ini.img_busy}];
_ctl_treeview1_onitemselected : function (profile, item, src) {
xui.message(item.id + " was selected!");
_ctl_treeview1_afterfold : function (profile, item) {
xui.message(item.id + " is fold!");
_ctl_treeview1_afterexpend : function (profile, item) {
xui.message(item.id + " is expand!");
Site Admin
Posts: 102
Joined: Thu Apr 25, 2013 6:51 am

Return to CrossUI Code Snaps

Who is online

Users browsing this forum: No registered users and 1 guest