工作笔记(一)

1. 在datagrid上添加“查询”按钮,对datagrid列出的数据进一步筛选。

“查询”按钮触发的事件:

//获取筛选的数据值

var colNameSearch = $('#colNameSearch').val();

//调用datagrid的方法

$('#communityManage').datagrid('load',{

colName :colNameSearch   //参数

});

2 . 对日期进行格式化,网上看到的,感觉不错,放在此处以防忘记:

/*
 * 为Date添加一个formatDate,用来格式化日期
 * 
 * yyyy 年
 * MM 月
 * dd 日
 * hh 小时
 * mm 分
 * ss 秒
 * qq 季度
 * S  毫秒
 * 
 * format:yyyy-
 * 
 * cnfengqinag  2015-04-07
 */
Date.prototype.formatDate = function (format) 
{
    var o = {
        "M+": this.getMonth() + 1, //month
        "d+": this.getDate(),    //day
        "h+": this.getHours(),   //hour
        "m+": this.getMinutes(), //minute
        "s+": this.getSeconds(), //second
        "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter
        "S": this.getMilliseconds() //millisecond
    };
    if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
    (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o) if (new RegExp("(" + k + ")").test(format))
        format = format.replace(RegExp.$1,
      RegExp.$1.length == 1 ? o[k] :
        ("00" + o[k]).substr(("" + o[k]).length));
    return format;
};

对于一个使用毫秒来标记的日期,可做如下转换,得到一个时间对象:

var unixTimestamp = new Date(value);

3 . 发现的错误,数据库中的datatime类型对应到Java中的类型是java.sql.Timestamp,

今天同事使用的Date对应,在保存日期时报错。

原文地址:https://www.cnblogs.com/haoke/p/4399377.html