get id value from ComboInput (not caption value)

Develop and Deploy Cross-Browser Web Apps .

get id value from ComboInput (not caption value)

Postby macscripter » Sat Mar 01, 2014 12:06 am

Hi! Could you please help me with this easy issue? All I want is to get the id value from ComboInput, but I get the caption value. Here goes my code:

Code: Select all
// The default code is a com class (inherited from xui.Com)
Class('App', 'xui.Com',{
    // Ensure that all the value of "key/value pair" does not refer to external variables
    Instance:{
        // To initialize instance(e.g. properties)
        initialize : function(){
            // To determine whether or not the com will be destroyed, when the first UI control be destroyed
            this.autoDestroy = true;
            // To initialize properties
            this.properties = {};
        },
        // 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));};
           
            append((new xui.UI.ComboInput())
            .setHost(host,"ctl_comboinput165")
            .setLeft(170)
            .setTop(170)
            .setItems([{"id":"a", "caption":"item a", "image":"img/demo.gif"}, {"id":"b", "caption":"item b", "image":"img/demo.gif"}, {"id":"c", "caption":"item c", "image":"img/demo.gif"}, {"id":"d", "caption":"item d", "image":"img/demo.gif", "disabled":true}])
            .setInputReadonly(true)
            .onChange("_ctl_comboinput165_onchange")
            );
           
            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_sbutton1_onclick : function (profile, e, src, value) {
            var uictrl = profile.boxing();
            xui.alert("hi","I'm " + uictrl.getAlias());
        },
        _ctl_comboinput165_onchange:function (profile,oldValue,newValue){
            var ns = this, uictrl = profile.boxing();
            alert(newValue);
            alert(ns.ctl_comboinput165.getUIValue());
        }
    }
});
macscripter
 
Posts: 21
Joined: Wed Apr 24, 2013 12:53 pm

Re: get id value from ComboInput (not caption value)

Postby macscripter » Sat Mar 01, 2014 4:13 pm

I try to explain better my problem. In the caption I like to put a description for my users. But the id value is that I need to send it to my server.
Where am I wrong? Why do I get the caption for comboinput but for list I get the id value? Here goes my code to show this:

Code: Select all
// The default code is a com class (inherited from xui.Com)
Class('App', 'xui.Com',{
    // Ensure that all the value of "key/value pair" does not refer to external variables
    Instance:{
        // To initialize instance(e.g. properties)
        initialize : function(){
            // To determine whether or not the com will be destroyed, when the first UI control be destroyed
            this.autoDestroy = true;
            // To initialize properties
            this.properties = {};
        },
        // 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));};
           
            append((new xui.UI.ComboInput())
            .setHost(host,"c_comboinput")
            .setLeft(170)
            .setTop(170)
            .setItems([{"id":"a", "caption":"item a", "image":"img/demo.gif"}, {"id":"b", "caption":"item b", "image":"img/demo.gif"}, {"id":"c", "caption":"item c", "image":"img/demo.gif"}, {"id":"d", "caption":"item d", "image":"img/demo.gif", "disabled":true}])
            .setInputReadonly(true)
            .onChange("_ctl_comboinput165_onchange")
            );
           
            append((new xui.UI.List())
            .setHost(host,"c_list")
            .setItems([{"id":"a", "caption":"item a", "image":"img/demo.gif"}, {"id":"b", "caption":"item b", "image":"img/demo.gif"}, {"id":"c", "caption":"item c", "image":"img/demo.gif"}, {"id":"d", "caption":"item d", "image":"img/demo.gif", "disabled":true}])
            .setLeft(40)
            .setTop(100)
            .setValue("a")
            .onChange("_c_list_onchange")
            .onItemSelected("_c_list_onitemselected")
            );
           
            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_comboinput165_onchange:function (profile,oldValue,newValue){
            var ns = this, uictrl = profile.boxing();
            alert(newValue);
        },
        _c_list_onchange:function (profile,oldValue,newValue){
            var ns = this, uictrl = profile.boxing();
            alert(newValue);
        }
    }
});
macscripter
 
Posts: 21
Joined: Wed Apr 24, 2013 12:53 pm

Re: get id value from ComboInput (not caption value)

Postby macscripter » Sat Mar 01, 2014 10:05 pm

Ok, Just resolved by myself. Just needed to add: .setType("listbox") for xui.UI.ComboInput... That's all...

Code: Select all
// The default code is a com class (inherited from xui.Com)
Class('App', 'xui.Com',{
    // Ensure that all the value of "key/value pair" does not refer to external variables
    Instance:{
        // To initialize instance(e.g. properties)
        initialize : function(){
            // To determine whether or not the com will be destroyed, when the first UI control be destroyed
            this.autoDestroy = true;
            // To initialize properties
            this.properties = {};
        },
        // 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));};
           
            append((new xui.UI.List())
            .setHost(host,"c_list")
            .setItems([{"id":"a", "caption":"item a", "image":"img/demo.gif"}, {"id":"b", "caption":"item b", "image":"img/demo.gif"}, {"id":"c", "caption":"item c", "image":"img/demo.gif"}, {"id":"d", "caption":"item d", "image":"img/demo.gif", "disabled":true}])
            .setLeft(40)
            .setTop(100)
            .setValue("a")
            .onChange("_c_list_onchange")
            .onItemSelected("_c_list_onitemselected")
            );
           
            append((new xui.UI.ComboInput())
            .setHost(host,"c_comboinput")
            .setLeft(170)
            .setTop(170)
            .setType("listbox")
            .setItems([{"id":"a", "caption":"item a", "image":"img/demo.gif"}, {"id":"b", "caption":"item b", "image":"img/demo.gif"}, {"id":"c", "caption":"item c", "image":"img/demo.gif"}, {"id":"d", "caption":"item d", "image":"img/demo.gif", "disabled":true}])
            .setInputReadonly(true)
            .onChange("_ctl_comboinput165_onchange")
            );
           
            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_comboinput165_onchange:function (profile,oldValue,newValue){
            var ns = this, uictrl = profile.boxing();
            console.log(newValue);
            alert(newValue);
        },
        _c_list_onchange:function (profile,oldValue,newValue){
            var ns = this, uictrl = profile.boxing();
            alert(newValue);
        }
    }
});
macscripter
 
Posts: 21
Joined: Wed Apr 24, 2013 12:53 pm


Return to CrossUI for Web Apps

Who is online

Users browsing this forum: No registered users and 1 guest

cron