众所周知Oracle数据库中的date与众不同,在Easyui中显示数据库的date类型如果不经过转化为显示为Object。因此需要经过处理。

1、首先你要写转化date的JavaScript

<script type="text/javascript">
function formattime(val) {
var year=parseInt(val.year)+1900;
var month=(parseInt(val.month)+1);
month=month>9?month:('0'+month);
var date=parseInt(val.date);
date=date>9?date:('0'+date);
var hours=parseInt(val.hours);
hours=hours>9?hours:('0'+hours);
var minutes=parseInt(val.minutes);
minutes=minutes>9?minutes:('0'+minutes);
var seconds=parseInt(val.seconds);
seconds=seconds>9?seconds:('0'+seconds);
var time=year+'-'+month+'-'+date+' '+hours+':'+minutes+':'+seconds;
return time;
}
</script>

2、在Datagrid中调用这个函数

$(function() {
$('#tt').datagrid({
title : '表格信息',
iconCls : 'icon-ok',
width : 800,
height : 400,
pageSize : 10,
pageList : [ 5, 10, 15, 20 ],
nowrap : true,//设置为true,当数据长度超出列宽时将会自动截取
striped : true,//设置为true将交替显示行背景。
collapsible : true,//显示可折叠按钮
toolbar : "#tb",
url : 'load!queryTable.action?begindate=&enddate=&username=&ip=&operate=',
loadMsg : '数据装载中......',
singleSelect : true,//只能选择单行
fitColumns : true,//允许表格自动缩放,以适应父容器
remoteSort : false,
frozenColumns : [ [ {
field : 'ck',
checkbox : true
} ] ],
columns : [ [
{
title : '标题',
field : 'title',
width : '340',
rowspan : 2,
align : 'center'
},{
title : '类型',
field : 'cpersontype',
width : '120',
rowspan : 2,
align : 'center'
},
{
title : '上传时间',
field : 'loadtime',
width : '120',
rowspan : 2,
align : 'center',
formatter:function(val)
{ /* 调用函数显示时间 */
return formattime(val);
}
}] ],
pagination : true,//分页
rownumbers : true//行数
});
});

3、显示效果

4、在datetimebox控件中回填显示日期,在初始化$(function())中中添加代码

var mytime;
$('#time2').datetimebox();

5、在初始化$(function())中的$("#edittable").click(function()中添加代码

var row=$('#tt').datagrid('getSelected');
mytime=formattime(row.loadtime);/*loadtime是数据库中时间的字段*/
totime(mytime);/*调用totime方法*/

5、添加totime方法

function totime(val){
$('#time2').datetimebox('setValue',val);
}

6、对应的html代码

      <tr>
<td>上传时间</td>
<td><input name="time2" id="time2" > </td>
</tr>

6、成功在datetimebox控件中回填数据

Easyui获取数据库date数据的显示的更多相关文章

  1. jmeter 获取数据库表数据作为参数

    jmeter - 获取数据库表数据作为参数 在jmeter中使用数据库表数据首先需要设置数据库连接,然后在创建JDBC取样器 1.创建配置元件 JDBC Connection Configuratio ...

  2. String强制转换为Date,freemarker标签里date数据的显示问题

    String强制转换为Date,freemarker标签里date数据的显示问题 http://blog.sina.com.cn/s/blog_617f5d090101ut63.html (2014- ...

  3. ORM框架通过映射(反射)获取数据库的数据

    ORM(Object Relational Mapping)框架采用元数据来描述对象一关系映射细节,元数据一般采用XML格式,并且存放在专门的对象一映射文件中.只要提供了持久化类与表的映射关系,ORM ...

  4. 实现easyui datagrid在没有数据时显示相关提示内容

    本示例实现easyui datagrid加载/查询数据时,如果没有相关记录,则在datagrid中显示没有相关记录的提示信息,效果如下图所示 本实例要实现如下图所示的效果: 本示例easyui版本为1 ...

  5. jquery 获取json文件数据,显示到jsp页面上, 或者html页面上

    [{"name":"中国工商银行","code":102},{"name":"中国农业银行",&qu ...

  6. Jquert data方法获取不到数据,显示为undefined。

    在使用jquery的data-xxxx自定义属性名使用小写 以下是我测试代码: 结果显示Undefined 现在将“data-Name”变为“data-name”,将大写的部分全部变为小写. 可以获取 ...

  7. php获取数据库中数据,转成json数据

    <?php //需要执行的SQL语句 //单条 $sql="select * from xinwen"; //多条数据 //$sql="select id,name ...

  8. ajax获取数据库中数据

    xhr=new XMLHttpRequest(); var url="要获取数据的地方"; xhr.open('post',url,true); POST请求头(get就不用写这个 ...

  9. 从数据库读取数据后显示成html标签

    也许很多人从数据库中读的数据是不需要数据成html标签的,但是也许有一天你们会发现当我们需要输出成html标签时编译器却自动帮我们输出成字符串了这是我们可以这样来 方法1: 最常用的方法,使用JS或J ...

随机推荐

  1. 提高你的Java代码质量吧:让我们疑惑的字符串拼接方式的选择

    一.分析  对于一个字符串进行拼接有三种方法:加号.concat方法.及StringBuiler或StringBuffer. 1."+"方法拼接字符串  str += " ...

  2. 使用nice命令调整进程优先级

    Adjusting Process Priority with nice   When Linux processes are started, they are started with a spe ...

  3. querydsl的好处

    http://www.querydsl.com/ 封装了很多访问不同数据层平台的方法,提供统一的通用框架(统一的书写格式,以一种通用的API方式来构建查询).便于抽成统一数据层,昨晚底层,以后其他模块 ...

  4. Wcf资料收集

    1.简介 http://www.tuicool.com/articles/mqYB32 使用规范 http://blog.51cto.com/zt/219 2.教程系列 http://www.cnbl ...

  5. ThinkPhp3.2 无法加载模块:Index

    http://localhost:444/admin/index.php/Index/index出错:无法加载模块:Index http://localhost:444/admin/index.php ...

  6. url的非法字符有哪些

    需要过滤的特殊字符及字符串有: net user xp_cmdshell /add exec master.dbo.xp_cmdshell net localgroup administrators ...

  7. Jenkins学习之——(3)将项目发送到tomcat

    本章节将讲解如何将项目发送到tomcat,实现自动部署. 我只将一个测试的maven项目托管到github上的,不了解git获github的朋友自己百度一下,我也写了一些关于git的文章,希望大家可以 ...

  8. 修复 status 为 unusable 的 index

    以DBA权限登陆,执行以下脚本即可. declare     -- 指向所有 UNUSABLE 状态的 index 的游标      cursor c is        select index_n ...

  9. java第一天的疑问

    1字节 的 byte 2字节 的 char 精度 byte<short<char<int<long<float<double 随便打个整数默认为int 随便打个小数 ...

  10. printf格式输出总结

    #include<stdio.h>    #include<string.h>    int main()    {        ];        ;       floa ...