Page 1 of 1

How to load list of ComboInput dynamically

Posted: Thu May 30, 2013 3:40 am
by linb
   
Class('App', 'xui.Com',{
    Instance:{
        autoDestroy:true,
        iniComponents:function(){
            // [[Code created by CrossUI RAD Tools
            var host=this, children=[], append=function(child){children.push(child.get(0))};
            
            append(
                (new xui.UI.ComboInput)
                .setHost(host,"comboinput2")
                .setLeft(70)
                .setTop(30)
                .setType("listbox")
                .beforeComboPop("_comboinput2_beforecombopop")
            );
            
            return children;
            // ]]Code created by CrossUI RAD Tools
        },

        _comboinput2_beforecombopop:function (profile, pos, e, src) {
            var prop=profile.properties;
            if(prop.items.length==0){
                // Set face
                profile.boxing().setItems([{id:"Loading...", capiton:"Loading...", disabled:true}]);
                // // Try to get from cache first
                // var picklist = xxx.getFromCache...
                // if(picklist){
                //    profile.boxing().setItems(picklist);
                // }else{
                //    xui.request(xxx,{xxx},function(rsp){
                //        if(rsp){
                //            var items=[];
                //            // set to cache
                //            xxx.setCache...;
                //            // set data to comboInput
                //            profile.boxing().setItems(items);
                //        }else{
                //            // if it's fail, collapse it
                //            profile.boxing().setItems([]).collapse();
                //        }
                //    },function(){
                //        // if it's fail, collapse it
                //        profile.boxing().setItems([]).collapse();
                //    });
                //}
                
                // To simulate Ajax
                _.asyRun(function(){
                    profile.boxing().setItems([{id:'a',caption:'item a'},{id:'b',caption:'item b'}]);
                },500);
            }
        }
    }
});
Class('App', 'xui.Com',{
    Instance:{
        autoDestroy:true,
        iniComponents:function(){
            // [[Code created by CrossUI RAD Tools
            var host=this, children=[], append=function(child){children.push(child.get(0))};
            
            append(
                (new xui.UI.ComboInput)
                .setHost(host,"comboinput2")
                .setLeft(70)
                .setTop(30)
                .setType("listbox")
                .beforeComboPop("_comboinput2_beforecombopop")
            );
            
            return children;
            // ]]Code created by CrossUI RAD Tools
        },

        _comboinput2_beforecombopop:function (profile, pos, e, src) {
            var prop=profile.properties;
            if(prop.items.length==0){
                // Set face
                profile.boxing().setItems([{id:"Loading...", capiton:"Loading...", disabled:true}]);
                // // Try to get from cache first
                // var picklist = xxx.getFromCache...
                // if(picklist){
                //    profile.boxing().setItems(picklist);
                // }else{
                //    xui.request(xxx,{xxx},function(rsp){
                //        if(rsp){
                //            var items=[];
                //            // set to cache
                //            xxx.setCache...;
                //            // set data to comboInput
                //            profile.boxing().setItems(items);
                //        }else{
                //            // if it's fail, collapse it
                //            profile.boxing().setItems([]).collapse();
                //        }
                //    },function(){
                //        // if it's fail, collapse it
                //        profile.boxing().setItems([]).collapse();
                //    });
                //}
                
                // To simulate Ajax
                _.asyRun(function(){
                    profile.boxing().setItems([{id:'a',caption:'item a'},{id:'b',caption:'item b'}]);
                },500);
            }
        }
    }
});