您的位置:首页 > 产品设计 > UI/UE

easyui重置表单以及clear和reset的区别

2017-04-20 20:08 337 查看
区别:clear将表单所有值都清空,包括combobox和日期框。 reset会还原成你在页面上写的样式。



图上表单中的发起日期、生效日期、失效日期、计划运行日期都是在js中设置的当前日期、始发地也是在js中写的默认网点,但那些combobox都是在jsp上写死的选项。

现在的需求是:点重置使页面恢复为现在的样子。

用$('#').form('clear')会将所有框都清空,包括combobox。

用$('#').form('reset')则只会清空日期框,不会清空combobox。

所有最后的解决方案是:

function dateboxBind() {
$('#createOrderTm').datebox('setValue', getCurentDateStr());
$('#invalidTm').datebox('setValue', getCurentDateStr());
$('#effectiveTm').datebox('setValue', getCurentDateStr());
$('#lineRequireDate').datebox('setValue', getCurentDateStr());
$('#lineRequireDate').datebox('calendar').calendar({
validator : function(date) {
var now = new Date();
var d1 = new Date(now.getFullYear(), now.getMonth(), now
.getDate());
return date <= d1;
}
});
// 设置始发地为用户所在区部代码
$.ajax({
url : contextPath + getCurrAreaCodeUrl,
type : 'post',
success : function(data) {
if (data.success) {
$('#srcZoneCode').textbox('setValue', data.currentAreaCode);
} else {
showMessage('加载当前用户所在区部为始发地失败!');
}
},
error : function() {
$.messager.alert('警告', '后台错误,请联系管理员!', 'warning');
}
});
};

function resetBind(){
$('#resetBtn').click(function(){
$('#searchForm').form('reset');
dateboxBind();
});
}利用form的reset方法重置其它框,重新调用dateboxBind()方法恢复时间框等。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: