Created
December 23, 2016 14:57
-
-
Save YeomanYe/0f9d19f456c4f038030eb9b8602dc16e to your computer and use it in GitHub Desktop.
EasyUI:dynamicPageGrid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* columns示例:[[{field:'parentId',title:'字段A',width:400,halign:"center",align:"center", formatter:function(value, row, index){return getParent(row.parentId);}}]] | |
* 动态生成数据表格 | |
* @param {object/string} arg url字符串或者设置对象 | |
* @param {string} datagridId datagrid的Id | |
* @param {array} columns 数据列定义,二维数组 | |
*/ | |
function dynamicPageGrid(arg,datagridId,columns){ | |
var option = { | |
//每页大小 | |
size: arg.size ? arg.size : 20, | |
//工具栏Id | |
toolbarId: arg.toolbarId ? arg.toolbarId : "toolbar", | |
//url | |
url: arg.url ? arg.url : arg, | |
//datagridId | |
datagridId: arg.datagridId ? arg.datagridId : datagridId, | |
//columns | |
columns: arg.columns ? arg.columns : columns, | |
//标题 | |
caption: arg.caption ? arg.caption : "数据表格", | |
}; | |
var pageSize = option.size; | |
$("#"+option.datagridId).datagrid({ | |
url:option.url, | |
striped:true, | |
title:option.caption, | |
rownumbers:true, | |
pagination:true, | |
pageSize:pageSize, | |
pageList:[pageSize,pageSize*2,pageSize*3,pageSize*4,pageSize*5], | |
pageNumber:1, | |
fit:true, | |
fitColumns:true, | |
columns:option.columns, | |
toolbar:"#"+option.toolbarId | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment