jqGrid后台交互样例

Posted 馳騁衿琾

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jqGrid后台交互样例相关的知识,希望对你有一定的参考价值。

schoolManageGrid = $("#jqGrid").jqGrid({
url : ctx.path+"/api/school/querySchools",
mtype:"POST",
datatype: "json",
height:contentHeight,
colNames: [‘序号‘, ‘所属区域‘, ‘学校名称‘, ‘校长‘,‘联系电话‘,‘学校类型‘, ‘‘, ‘操作‘,‘state‘],
colModel: [
{ name: ‘schoolId‘, index: ‘schoolId‘, width: 60, sorttype: "int", hidden : true },
{ name: ‘addressName‘, index: ‘addressName‘, width: 80 },
{ name: ‘schoolName‘, index: ‘schoolName‘, width: 100 },
{ name: ‘contact‘, index: ‘contact‘, width: 100 },
{ name: ‘phone‘, index: ‘phone‘, width: 100 },
{ name:‘schoolTypeName‘, index:‘schoolTypeName‘},
{ name:‘schoolTypeId‘, index:‘schoolTypeId‘, width : 0, hidden : true},
{ name : ‘act‘,index : ‘act‘,width : 100,align:‘center‘, sortable : false },
{ name : ‘state‘,index : ‘state‘, hidden : true}
],
gridComplete : function() {
var ids =schoolManageGrid.jqGrid(‘getDataIDs‘);
for ( var i = 0; i < ids.length; i++) {
var cl = ids[i];
var rowData = schoolManageGrid.jqGrid(‘getRowData‘,cl);
if(rowData.state==1){
enable= "<a href=\"javascript:void(0)\" style=‘vertical-align:middle;‘ onclick=\"enableClick("+rowData.state+","+rowData.schoolId+",‘"+rowData.schoolName+"‘);\" >禁用</a>";
}else{
enable= "<a href=\"javascript:void(0)\" style=‘vertical-align:middle;‘ onclick=\"enableClick("+rowData.state+","+rowData.schoolId+",‘"+rowData.schoolName+"‘);\" >启用</a>";
}

eid = "<div class=‘edit‘ title=‘编辑‘ style=‘vertical-align:middle;‘ onclick=\"editUser("+ rowData.schoolId+",‘"+rowData.schoolName+"‘,‘"+rowData.contact+"‘,‘"+rowData.phone+"‘,‘"+rowData.schoolTypeId+"‘);\" ></div>";
schoolManageGrid.jqGrid(‘setRowData‘, ids[i],
{
act : enable +"<span style=‘width:40px;display: inline-block;‘></span>" + eid
});
}


},
multiselect:false,
autowidth: true,//自适应宽度
shrinkToFit: true,
rowNum : 20,
rowList: [10, 20, 50],
rownumbers:true,//添加左侧行号
altRows:true,//设置为交替行表格,默认为false
pager : ‘#jqGridPager‘,
viewrecords: true, //是否在浏览导航栏显示记录总数
hidegrid: false,
jsonReader: {
   root: "data.data",// Json数据
records: "data.totalRows",// 总记录数
total:"data.totalPages",
page:"data.page",
repeatitems: false
   }
});

以上是关于jqGrid后台交互样例的主要内容,如果未能解决你的问题,请参考以下文章

旋转字符串

[CSP-S模拟测试]:花(DP)

[CSP-S模拟测试]:简单的括号序列(组合数)

916. 回文排列

[CSP-S模拟测试]:爬(贪心)

513. 完美平方