Easyui datetimebox OK

Source: Internet
Author: User

 

I. The datetimebox OK button does not have an event to be clicked, but the onselect event can be used to simulate the "same effect as clicking the OK button". My code:
Key:
0. Understand the datetimebox control. This control is composed of the datebox + timespinner controls, and datebox inherits from the combo control.
1. Use the settext method to set the content of the control text box. This method is inherited from the combo control by datetimebox. The setvalue method cannot be used because it is inherited from datebox, but the datetimebox control does not override this method. Because datetimebox also contains "time, minute, and second", the datebox method cannot be used.
2. Use the spinner method to obtain the "time, minute, and second" information. This method returns the timespinner control contained in datetimebox. Use the getvalue method of the timespinner control to obtain the time information.
3. Use the onselect method to obtain the "date" information. onselect: function (date) {}, where date is the date selected when the event is triggered and is the date data of Js.
4. Use the hidepanel method to close the drop-down date panel. This method also inherits from the combo control.
Easy-to-understand code:
$ ('# Textstarttime'). datetimebox ({
Showseconds: false,
Required: True,
Onselect: function (date ){
VaR time = $ ('# textstarttime'). datetimebox ('json'). spinner ('getvalue ');
$ ('# Textstarttime '). datetimebox ('settext', date. getfullyear () + '-' + (date. getmonth () + 1) + '-' + date. getdate () + ''+ time );
$ ('# Textstarttime'). datetimebox ('hidemopanel ');
}
});

Let the code format be changed:
$ ('# Textstarttime'). datetimebox ({
Showseconds: false,
Required: True,
Onselect: function (date ){
VaR time = $ ('# textstarttime'). datetimebox ('json'). spinner ('getvalue ');
$ ('# Textstarttime'). datetimebox ('settext', date. getfullyear () + '-' + (date. getmonth () + 1) <10? ('0' + (date. getmonth () + 1): (date. getmonth () + 1) + '-' + (date. getdate () <10? ('0' + (date. getdate (): (date. getdate () + ''+ time );
$ ('# Textstarttime'). datetimebox ('hidemopanel ');
}
});

 

Ii. Date formatting

VaR sysformat = function (time, format ){
VaR T = new date (time );
VaR TF = function (I) {return (I <10? '0': '') + I };
Return format. Replace (/YYYY | mm | dd | HH | mm | SS/g, function (){
Switch (){
Case 'yyyy ':
Return TF (T. getfullyear ());
Break;
Case 'mm ':
Return TF (T. getmonth () + 1 );
Break;
Case 'mm ':
Return TF (T. getminutes ());
Break;
Case 'dd ':
Return TF (T. getdate ());
Break;
Case 'hh ':
Return TF (T. gethours ());
Break;
Case 'ss ':
Return TF (T. getseconds ());
Break;
}
})
}

Easyui datetimebox OK

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.