EasyUI datetimebox时间设置问题
来源:互联网 发布:js array slice 编辑:程序博客网 时间:2024/04/28 23:43
这几天在做后管理框架,免不了需要根据时间段进行查询。因为使用了EasyU1.4框架,同时指定easyui-lang-zh_CN.js为本地语言库,时间控制就使用了datetimebox组件,组件本身没有什么问题,只是在设置组件值时出现问题:主要现象就是指定的时间值,无法设置到组件上,组件时间一直显示当前时间。以下是几个类的代码:
视图模型ExceptionSearchViewModel:
<pre class="csharp" style="background: white; color: black; font-family: 微软雅黑; font-size: 16px;" name="code">using System;namespace EPF.linxy.Web.Core.Model{ public class ExceptionSearchViewModel { public ExceptionSearchViewModel() { EndTime = DateTime.Now; StartTime = EndTime.AddDays( -7 ); } public DateTime StartTime { get; set; } public DateTime EndTime { get; set; } public String ControllerName { get; set; } public String ActionName { get; set; } public String ExceptionType { get; set; } }}
页面视图部分代码:
<div id="_exec_tb" style="padding:5px;height:auto;"> <div style="margin:5px;padding:0 0 0 15px"> 异常类型:<input id="ExceptionType" class="inputClass" type="text" name="ExceptionType" /> 模块名称:<input id="ControllerName" class="inputClass" type="text" name="ControllerName" /> 业务环节:<input id="ActionName" class="inputClass" type="text" name="ActionName" /> 起止时间:<input id="StartTime" type="text" name="StartTime" class="easyui-datetimebox" value="@Model.StartTime" /> To:<input id="EndTime" type="text" name="EndTime" class="easyui-datetimebox" value="@Model.EndTime" /> <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',width:70" onclick="doExecSearch()">查询</a> </div></div>
最终得出的效果如下:
通过上述方式无法正常设置控件值。
经过仔细研究,终于发现问题所在。EasyUi的Datetimebox使用的格式为"yyyy-mm-dd HH:mm:ss",而C#Model对象的Datetime类型默认取得的String值 格式 为"yyyy/MM/dd HH:mm:ss"。两种格式不匹配,DatetimeBox在解析时认为这是一个非法的Date字符串,会默认使用new Date()做为当前DatetimeBox框的值,就出现上述问题。
要解决以上问题,有两种办法:
1、在给Input框设置value属性值时,直接进行字符串格式化value="@Model.EndTime.ToString("yyyy-MM-dd HH:mm:ss")";
2、修改easyui-lang-zh_CN.js本地语言库,修改$.fn.datebox.defaults.parser 和 $.fn.datebox.defaults.formatter 的定义,将'-'符号替换为'/'符号即可。需要注意的是,采用这种方法以后升级Easyui库时,记得备份这个文件,或者直接将这个定义放在其它自定义的JS文件中。
以下两种方法,任意一种都可以解决上述问题。
0 0
- EasyUI datetimebox时间设置问题
- easyui datetimebox设置默认时间
- EasyUI--datebox设置默认时间【dateTimeBox类似】
- 使用jquery easyui datetimebox 设置默认时间
- EasyUI datetimebox设置默认值为当前时间
- EasyUI datetimebox 时间格式化
- EasyUI datetimebox显示当前时间
- easyui datetimebox setvalue 设置值
- easyui 像狗屎一样的框架 怎么设置datetimebox的值为当前时间, 怎么情况datetimebox的值
- easyui 像狗屎一样的框架 怎么设置datetimebox的值为当前时间, 怎么情况datetimebox的值
- easyui的datetimebox时间格式化详解
- easyui-datetimebox默认显示当前时间
- jQuery EasyUI - DateTimeBox 日期时间框
- easyui dateTimeBox超过当前时间灰掉
- 使用Jquery EasyUI中DateTimeBox控件设置考试开始结束时间,并对其验证
- EasyUI datetimebox设置默认时分秒
- easyUI DateTimeBox
- EasyUI 中关于datetimebox赋值问题
- PHP自学--制图
- Longest Consecutive Sequence
- nyoj 题号12 喷水装置(二)——南阳oj
- ORACLE ASM 转自三思笔记
- matlab 读取文件技巧 经典中的经典
- EasyUI datetimebox时间设置问题
- HAVING 与where
- Adding new Code to your GitHub Repository
- SQL SERVER 数据库所用端口设置
- android平台下lcd调试流程如下
- HttpClient(访问网络) get方式,post方式。返回值有String,InputStream,byte[]
- Android SDK更新失败的解决办法
- Matlab常用函数
- Hadoop实战视频教程下载