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

编程入门 行业动态 更新时间:2024-10-26 14:39:44

EasyUI editor datebox进入编辑<a href=https://www.elefans.com/category/jswz/34/1771386.html style=状态时值置空问题"/>

EasyUI editor 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);planSendWeekdaybobox("setValue",week);}
});
//附上初始值
planSendDate.datebox("setValue",hvalue);
  • That’s all.

更多推荐

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

本文发布于:2024-02-17 06:43:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1693058.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:状态   编辑   EasyUI   editor   datebox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!