当前位置: 移动技术网 > IT编程>开发语言>JavaScript > EasyUI editor datebox进入编辑状态时值置空问题

EasyUI editor datebox进入编辑状态时值置空问题

2020年08月08日  | 移动技术网IT编程  | 我要评论
问题描述EasyUI的行编辑editor在进入编辑状态后,如果行里存在datebox,这时是没有问题的,可以正常使用,但是如果在进入编辑状态后,在js代码再使用.datebox()方法初始化datebox框,就会清空datebox中现有的值。页面看到的还是有值的,实际提交到后台的已经是空字符串了。感觉这是框架的一个bug(纯属猜测)解决思路其实思路很简单,值是在再次使用.datebox()方法初始化datebox框后置空的,那么我们可以在置空前使用变量保存值,在置空后再给附上,这样既保留了..
  • 问题描述

    EasyUI的行编辑editor在进入编辑状态后,如果行里存在datebox,这时是没有问题的,可以正常使用,但是如果在进入编辑状态后,在js代码再使用.datebox()方法初始化datebox框,就会清空datebox中现有的值。
    页面看到的还是有值的,实际提交到后台的已经是空字符串了。
    感觉这是框架的一个bug(纯属猜测)在这里插入图片描述

  • 解决思路
    其实思路很简单,值是在再次使用.datebox()方法初始化datebox框后置空的,那么我们可以在置空前使用变量保存值,在置空后再给附上,这样既保留了初始值,又加载了我们的.datebox()新属性,两不耽误。

  • 代码
    HTML:

<th data-options="field:'planSendDate',width:fixWidth(0.12),align:'center',
editor:{
	type:'datebox',
	options:{
		required:true,
		editable:false
	}
}">发运日期</th> 

JS:

//日期和周几联动 var planSendDate = $(this).datagrid('getEditor', {'index':editingIndexQC,'field':'planSendDate'}).target; var planSendWeekday = $(this).datagrid('getEditor', {'index':editingIndexQC,'field':'planSendWeekday'}).target; //保留初始值 var hvalue = planSendDate.datebox("getValue"); //加载新属性,同时会置空值 planSendDate.datebox({ onSelect:function() { var newDate = planSendDate.datebox("getValue"); var week = getWeek(newDate); planSendWeekday.combobox("setValue",week); } }); //附上初始值 planSendDate.datebox("setValue",hvalue); 
  • That’s all.

本文地址:https://blog.csdn.net/weixin_42857643/article/details/107865763

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网