当前位置:网站首页>EasyUI date control emptying value

EasyUI date control emptying value

2022-07-07 21:05:00 Full stack programmer webmaster

Hello everyone , I meet you again , I'm the king of the whole stack .

Recently used Easyui Date control for datebox, Clear the selected value in the project , So I studied .

1. Call method to clear

$('#yourId').combo('setText','');

2, change js file

In the source file downloaded from the official website .datebox The control interface only has ‘Today’.‘Close’ event . We can add the event of clearing the option value to js In the middle , such , Just quote datebox This control , There will be an empty option on the interface . The detailed change process is as follows :

First, download it from the official website jquery.easyui.min.js file .

stay js Found in the file Today Close Where the event is defined , And add Clean Event definition .

Source file description :

Source file 12733–12742 Replace the 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 put the source js It's changed , Only the interface shows English , Suppose you use a Chinese bag , It still needs to be changed easyui-lang-zh_CN.js

stay js Found in the file ‘ today ’ ‘ close ’ Where the event is defined , And add ‘ Empty ’

Code :

	$.fn.datebox.defaults.currentText = ' today ';
	$.fn.datebox.defaults.closeText = ' close ';
	$.fn.datebox.defaults.cleanText = ' Empty ';

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

Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/116440.html Link to the original text :https://javaforall.cn

原网站

版权声明
本文为[Full stack programmer webmaster]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071843025581.html