代码可直接复用
var machineGrid;//网格定义
var url = PATH.BASEPATH+'/omPlatform/cluster/getSecondCatalog?userName='+userName1+'&upPath='+upPath1+'×='+secondTimes1;
$(function(){
getDateGrid();
});
/**
* 载入数据
*/
function getDateGrid(){
if(machineGrid){ //如果网格存在优先加载网格
machineGrid.datagrid('load',{
clusterId:clusterId//过滤参数
});
return;
}
machineGrid = $('#datagridDiv').datagrid({
url:url,
method:'post',
loadMsg : '正在加载数据...',
rownumbers:false,//序列号
nowrap:true,
pageSize:10,
striped:true,//行条纹化
pagination:false,//分页工具
pagePosition:'bottom',//分页栏位置
fitColumns:true,//宽度自适应
fit:true,//高度自适应
queryParams : { //url所携带的查询参数
clusterId:clusterId
},
columns:[[{
field : 'hdfsPath',
title : '名称',
width : 200,
align : 'center'
}, {
field : 'times',
title : '修改日期',
width : 200,
align : 'center'
}, {
field : 'pub',
title : '类型',
width : 100,
align : 'center'
}, {
field : 'allocatedMb',
title : '大小(G)',
width : 100,
align : 'center'
}]]
});
}
知识点:
(1)url是controller中的url,method为post,controller中也为method=RequestMethod.POST ;
(2)columns中的field必须和后台拿到的json数据字段名一样,否则无法匹配;