get the value of a comboInput type date

Develop and Deploy Cross-Browser Web Apps .

get the value of a comboInput type date

Postby stephane_adoma » Sun Jun 02, 2013 9:07 pm

Hi,
I search to get the valor of my comboInput with type date.
I have :
Code: Select all
 host.ctl_group136.append(
                (new xui.UI.ComboInput)
                .setHost(host,"input_date_debut")
                .setDomId("input_date_debut")
                .setDataBinder("DB_histo_search")
                .setDataField("input_date_debut")
      .setType("date")
                .setLeft(10)
                .setTop(10)
                .setWidth(150)
                .setLabelSize(60)
                .setLabelCaption("Du :")
                .setLabelHAlign("left")
               
            );
           
            host.ctl_group136.append(
                (new xui.UI.ComboInput)
                .setHost(host,"input_date_fin")
                .setDataBinder("DB_histo_search")
                .setDataField("input_date_fin")
      .setType("date")
                .setLeft(170)
                .setTop(10)
                .setWidth(130)
                .setLabelSize(30)
                .setLabelCaption("Au :")
                .setLabelHAlign("left")

            
            );


When i make a : xui.alert(_.serialize(this.DB_histo_search.updateDataFromUI().getData()));
after i have choose date i have this result : "input_date_debut":new Date(2013,5,2,0,0,0,0), "input_date_fin":new Date(2013,4,19,0,0,0,0),
But i search to have the text value of date : example 02-05-2013
I think i have forgot a very simple thing..but i listen the solution with attention :roll:
Thank
stephane_adoma
 
Posts: 3
Joined: Sat May 25, 2013 7:04 am

Re: get the value of a comboInput type date

Postby support » Mon Jun 03, 2013 1:03 am

The value in date ComboInput is an Date Object, you should format it if you want text result.

   
Class('App', 'xui.Com',{
Instance:{
iniComponents : function(){
// [[Code created by CrossUI RAD Tools
var host=this, children=[], append=function(child){children.push(child.get(0))};

append(
(new xui.UI.SButton)
.setHost(host,"ctl_sbutton6")
.setLeft(90)
.setTop(80)
.setWidth(120)
.setCaption("Get Date Value")
.onClick("_ctl_sbutton6_onclick")
);

append(
(new xui.UI.ComboInput)
.setHost(host,"ctl_comboinput25")
.setLeft(90)
.setTop(30)
.setType("date")
.setValue("1370016000000")
);

append(
(new xui.UI.SButton)
.setHost(host,"ctl_sbutton19")
.setLeft(90)
.setTop(120)
.setWidth(120)
.setCaption("Get Date Value")
.onClick("_ctl_sbutton19_onclick")
);

return children;
// ]]Code created by CrossUI RAD Tools
},
_ctl_sbutton6_onclick : function (profile, e, src, value){
var ns = this;
var v=ns.ctl_comboinput25.getUIValue();
xui.alert(xui.Date.format(v, "mm-dd-yyyy"));
},
_ctl_sbutton19_onclick : function (profile, e, src, value){
var ns = this;
var v=ns.ctl_comboinput25.getUIValue();
xui.alert(_.serialize(v,null,"gmt"));
}
}
});
   
support
 
Posts: 340
Joined: Sat Apr 27, 2013 9:22 am

Re: get the value of a comboInput type date

Postby stephane_adoma » Mon Jun 03, 2013 5:03 am

Thank you for your reply.
I understand that "the value in date ComboInput is an Date Object " but I use the function " _.serialize(this.DB_histo_search.updateDataFromUI().getData()" to submit all of my data to an ajax request that will feed a treegrid.
So I'm looking for an alternative that would allow me to directly submit a text value for my date so that it is directly used as a parameter for a sql query.
I try to put your function in a afterUIValueSet but it creates me a too much recursion when i set date in picker.
stephane_adoma
 
Posts: 3
Joined: Sat May 25, 2013 7:04 am

Re: get the value of a comboInput type date

Postby support » Mon Jun 03, 2013 5:41 am

   
Class('App', 'xui.Com',{
Instance:{
iniComponents : function(){
// [[Code created by CrossUI RAD Tools
var host=this, children=[], append=function(child){children.push(child.get(0))};

append(
(new xui.DataBinder)
.setHost(host,"databinder_1")
.setName("databinder_1")
.afterUpdateDataFromUI("_databinder_1_afterupdatedatafromui")
);

append(
(new xui.UI.ComboInput)
.setHost(host,"ctl_comboinput25")
.setDataBinder("databinder_1")
.setDataField("date")
.setLeft(90)
.setTop(30)
.setType("date")
.setValue("1370016000000")
);

append(
(new xui.UI.SButton)
.setHost(host,"ctl_sbutton19")
.setLeft(90)
.setTop(90)
.setWidth(120)
.setCaption("Get Date Value")
.onClick("_ctl_sbutton19_onclick")
);

return children;
// ]]Code created by CrossUI RAD Tools
},
_ctl_sbutton19_onclick : function (profile, e, src, value){
xui.alert(_.serialize(this.databinder_1.updateDataFromUI().getData()));
},
_databinder_1_afterupdatedatafromui : function (profile, dataFromUI){
_.each(dataFromUI,function(o,i){
if(_.isDate(o))
dataFromUI[i] = xui.Date.format(o,"mm-dd-yyyy");
});
}
}
});
   
support
 
Posts: 340
Joined: Sat Apr 27, 2013 9:22 am

Re: get the value of a comboInput type date

Postby stephane_adoma » Mon Jun 03, 2013 9:38 pm

Thank a lot, it's perfect !!
stephane_adoma
 
Posts: 3
Joined: Sat May 25, 2013 7:04 am


Return to CrossUI for Web Apps

Who is online

Users browsing this forum: No registered users and 2 guests

cron