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
});
}