6.11 星期二

6.11 星期二

一.beetlsql学习

二.datagrid的formatter  
$('#dg').datagrid({
    columns:[[
        {field:'userId',title:'User', width:80,
            //value 当前列的值
            //row 当前行(是一个对象)
            //index 当前行的索引
            formatter: function(value,row,index){
                //return必须得返回字符串
                return value;
            }
        }
    ]]
});


三.将长整型数字转化为标准化的时间格式
1、前台利用formatter进行日期格式转化
{
    title:'创建时间',
    field:'createdatetime',
    sortable:true,
    width:150,
    formatter:function(r){
    //要扩展javascript的format方法
        return new Date(v).format();
    }
}

2、后台利用fastJson将一个Date对象转化为字符串
JSON.toJsonStringWithDateFormat(object,"yyyy-MM-dd HH:mm:ss");

四、datagrid的行列样式
行样式:rowStyler
需要返回字符串
rowStyler:function(rowIndex,rowDate){
    //让所有name!=admin的行的背景色变红
    if(rowData.name=='admin'){
        return '';
    }
    return 'background:red';
}

列样式:styler
写在columns里面
styler:function(value,rowDate,rowIndex){
    //让所有name!=admin的行的背景色变红
    if(rowData.name=='admin'){
        return '';
    }
    return 'background:red';
}

猜你喜欢

转载自www.cnblogs.com/houchen/p/11006457.html
今日推荐