Easyui Date Control Empty value

Source: Internet
Author: User

Recently, the Easyui date control Datebox was used to clear the selected values in the project, so it was studied.


1, call method empty

$ (' #yourId '). Combo (' SetText ', ');

2. Change JS file

From the source file downloaded from the official website, the Datebox control interface has only ' Today ', ' Close ' event, we can add the empty option value of the event to JS, so as long as the reference to the Datebox this control, the interface will have the empty option. The specific steps are as follows:

First download the Jquery.easyui.min.js file on the official website.

Locate the Today Close event definition in the JS file and add the definition of the clean event.

Source File Description:

Replace the source file 12733--12742 line file with:


Code:

}},currenttext: "Today", Cleantext: "Clean", Closetext: "Close", Oktext: "OK", Buttons:[{text:function (_985) {
return $ (_985). Datebox ("Options"). Currenttext;
},handler:function (_986) {
$ (_986). Datebox ("Calendar"). Calendar ({year:new date (). getFullYear (), Month:new date (). GetMonth () +1,current:new date ()});
_975 (_986);
}},{text:function (_987) {
return $ (_987). Datebox ("Options"). Closetext;},handler
: function (_988) {
$ (this). Closest ("Div.combo-panel"). Panel ("Close");
}},{text:function (_989) {

return $ (_989). Datebox ("Options"). Cleantext;

},handler:function (_990) {

$ (_990). Combo (' SetValue ', '). Combo (' SetText ', ');

$ (this). Closest ("Div.combo-panel"). Panel ("Close");

}}],formatter:function (date) {

The interface effect is as follows:



3, Chinese JS change

Above we have changed the source JS, but the interface is displayed in English, if the use of Chinese bag, but also need to change the easyui-lang-zh_cn.js

In the JS file, locate the ' Today ' ' close ' event definition and add ' empty '

Code:

	$.fn.datebox.defaults.currenttext = ' Today ';
	$.fn.datebox.defaults.closetext = ' off ';
	$.fn.datebox.defaults.cleantext = ' empty ';


To modify an event:


Code:

if ($.fn.datetimebox && $.fn.datebox) {
	$.extend ($.fn.datetimebox.defaults,{
		cleantext: $. Fn.datebox.defaults.cleanText,
		currenttext: $.fn.datebox.defaults.currenttext,
		closetext: $. Fn.datebox.defaults.closeText,
		oktext: $.fn.datebox.defaults.oktext,
		missingmessage: $. Fn.datebox.defaults.missingMessage
	});
}


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.