//表格属性:page,elem,url,cols
//列属性:type,field,title
table.render({
//1 开启分页
page: true,
//2 指定渲染的table容器
elem: '#articleList',
//3 异步访问的路径
url: '../../user',
//4 集合属性
cols: [[
{type: 'checkbox'},
//4.1 普通属性
{field: 'username', title: '用户名称',width:'11%'},
//4.2 单选框属性
{field: 'sex', title: '性别', width:'11%'},
//4.3 复选框属性
{field: 'status', title: '状态', templet: '#status',width:'11%'},
//4.4 日期属性
{field: 'updated', title: '最近修改时间',width:'14%',
//日期格式转化
templet: function createTime(d){
return new Date(parseInt(d.updated)).toLocaleString()
}
},
]]
//4.2 数字条件判断
,done:function(res,curr,count){
$("[data-field='sex']").children().each(function(){
//若选取元素为1
if($(this).text() == '1'){
$(this).text('男');
//若选取元素为0
}else if($(this).text() == '0'){
$(this).text('女');
}
});
}
});
//4.4 调用的日期格式转化器
Date.prototype.toLocaleString = function() {
var y = this.getFullYear();
var m = this.getMonth()+1;
m = m<10?'0'+m:m;
var d = this.getDate();
d = d<10?("0"+d):d;
var h = this.getHours();
h = h<10?("0"+h):h;
var M = this.getMinutes();
M = M<10?("0"+M):M;
var S=this.getSeconds();
S=S<10?("0"+S):S;
return y+"-"+m+"-"+d;
/*+" "+h+":"+M+":"+S*/
};