jqgrid封装

<%--初始化表格列表组件 --%>
function initGrid() {
<%--#hostComputerId获取DIV id--%>
$('#hostComputerId').initBsGrid(
{
url: '${pageContext.request.contextPath}/accountManger/queryAccount!searchAccount.action?CSRFToken_HW=${randomStr_HW }&nav=nav3',
multiselect: false,
loadComplete: afterLoadEvent,
sortorder: "desc",
sortname: "createtime",
viewrecords : true,
colNames:["","<s:text name='bs.account.username'/>","<s:text name='bs.account.status'/>",
"<s:text name='bs.account.email'/>","<s:text name='bs.account.createtime'/>",
"<s:text name='bs.common.operate'/>"
],
colModel:
[
{name:'userid',index:'userid', hidden:true},      
{name:'username',index:'username',align:'left',width:150},
{name:'status',index:'status', width:80, align:'center',formatter:function(cellval, opts)
{
<%--根据状态值判断,显示不同字体颜色--%>
if(cellval == "<s:text name='bs.account.statusOK'/>"){
return "<s:text name='bs.account.statusOK'/>";
}
if(cellval == "<s:text name='bs.account.statusFal'/>"){
return "<span style='color:red'><s:text name='bs.account.statusFal'/></span>";
}
}},
{name:'email',index:'email', width:150}, 
{name:'createtime',index:'createtime', width:190, align:"center",sorttype:"date"},
{name:'operator',index:'operator', width:100,sortable:false,resizable:false,fixed:true,
formatter:function(cellval, opts){
return "<center title=' '>"
+"<div id='"+opts.rowId+"' title='' class='menu_div' style='border:solid blue 0px'>"
+"<a class='menu_oper' style='cursor:pointer;text-decoration:none'>"
+"<s:text name='bs.spec.list.operaper'/>&nbsp;<img src='${pageContext.request.contextPath}/resources/images/sh_zy_jt.png' />"
+"</a><div></center>";
}
}
]
});
}




<%--分页 --%>
function doPagerAction(pageIndex)
   {
   $("#hostComputerId").trigger("reloadGrid",[{page:pageIndex}]);
    }

<%--查询 --%>
function doSearchAction()
{
var text = $("#condition").val();
$("#hostComputerId").jqGrid("setGridParam",{url:encodeURI(encodeURI("${pageContext.request.contextPath}/accountManger/queryAccount!searchAccount.action?CSRFToken_HW=${randomStr_HW }&nav=nav3"+
"&condition=" + text)),page:1}).trigger("reloadGrid");
}

猜你喜欢

转载自vincenlxn.iteye.com/blog/1454441