说明:jqgrid属性colModel的字段排序,在于三个参数sortable:true,sortname:'name',sortorder:'asc'
下面附上列子:
function initList(){
var height = getTabContentHeight()-133;
var width = window.parent.document.documentElement.clientWidth-(window.screenLeft-window.parent.screenLeft)-186;
$("#list").jqGrid({
url:'<%=basePath%>customer!list.action',
colModel: [
{label:'企业名称', name:'name', align:"center",width:220},
{label:'企业编号', name:'code',align:"center",width:60},
{label:'企业性质', name:'type.title',index:'type', align:"center",width:60,hidden:true},
{label:'入驻状态', name:'parkStatus.title',index:'parkStatus',align:"center",width:60},
{label:'招商项目ID', name:'investmentId', align:"center",hidden:true},
{label:'账号', name:'userId', align:"center", hidden:true},
{label:'跟踪引进', name:'hostName', align:"center", hidden:true},
{label:'技术领域', name:'technic.dataValue', align:"center", hidden:true},
{label:'企业来源', name:'source.dataValue', align:"center", hidden:true},
{label:'孵化企业', name:'incubated.title',index:'incubated', align:"center",width:60},
{label:'孵化器配置', name:'incubationInfo.incubateConfig.dataValue',index:'incubationInfo.incubateConfig', align:"center",width:120},
{label:'联系地址', name:'customerInfo.address', align:"center", hidden:true},
{label:'邮编', name:'customerInfo.zipCode', align:"center", hidden:true},
{label:'网址', name:'customerInfo.webSite', align:"center", hidden:true},
{label:'办公电话', name:'customerInfo.officePhone', align:"center", hidden:true},
{label:'传真', name:'customerInfo.fax', align:"center", hidden:true},
{label:'Email地址', name:'customerInfo.email', align:"center", hidden:true},
{label:'注册时间', name:'customerInfo.regTime', align:"center", hidden:true,formatter:'date',formatoptions:{srcformat: 'Y-m-d', newformat: 'Y-m-d'}},
{label:'注册类型', name:'customerInfo.regType.dataValue', align:"center", hidden:true},
{label:'注册资本', name:'customerInfo.regCapital', align:"center", hidden:true},
{label:'币种', name:'customerInfo.currencyType.dataValue', align:"center", hidden:true},
{label:'组织机构', name:'customerInfo.organizationNumber', align:"center", hidden:true},
{label:'工商注册号', name:'customerInfo.businessNumber', align:"center", hidden:true},
/* {label:'税务登记证', name:'customerInfo.taxNumber', align:"center", hidden:true}, */
{label:'法定代表人', name:'customerInfo.legalPerson', align:"center", hidden:true},
{label:'证件类型', name:'customerInfo.documentType.dataValue', align:"center", hidden:true},
{label:'证件号', name:'customerInfo.documentNumber', align:"center", hidden:true},
{label:'注册EMAIL', name:'customerInfo.regMail', align:"center", hidden:true},
{label:'移动电话', name:'customerInfo.cellphone', align:"center", hidden:true},
{label:'注册地址', name:'customerInfo.regAddress', align:"center", hidden:true},
{label:'经营范围', name:'customerInfo.businessScope', align:"center", hidden:true},
{label:'营业截至日期', name:'customerInfo.businessExpireDate', align:"center", hidden:true,formatter:'date',formatoptions:{srcformat: 'Y-m-d', newformat: 'Y-m-d'}},
{label:'孵化日期起', name:'incubationInfo.incubationStartDate', align:"center", hidden:true,formatter:'date',formatoptions:{srcformat: 'Y-m-d', newformat: 'Y-m-d'}},
{label:'孵化日期止', name:'incubationInfo.incubationEndDate', align:"center", hidden:true,formatter:'date',formatoptions:{srcformat: 'Y-m-d', newformat: 'Y-m-d'}},
{label:'毕业日期', name:'incubationInfo.graduationDate', align:"center", hidden:true,formatter:'date',formatoptions:{srcformat: 'Y-m-d', newformat: 'Y-m-d'}},
{label:'是否高新技术企业', name:'incubationInfo.highTechEnterprise.title', align:"center", hidden:true},
{label:'是否建立创业导师', name:'incubationInfo.tutorSupport.title', align:"center", hidden:true},
{label:'是否大学生创业', name:'incubationInfo.undergraduateEnterprise.title', align:"center", hidden:true},
{label:'是否留学生创业', name:'incubationInfo.overseaEnterprise.title', align:"center", hidden:true},
{label:'孵化状态', name:'incubationInfo.statusName', align:"center",width:120},
{label:'管理', name:'manager', align:"center",width:80,sortable:false, resizable:false}
],
height: height,
width: width,
rowNum:40,
rowList:[40,80,160,320],
sortable:true,
sortname:'code',
sortorder:'asc',
shrinkToFit: false,
gridComplete: function(){
var ids = $(this).jqGrid('getDataIDs');
for(var i = 0 ; i < ids.length; i++){
var id = ids[i];
var content = "";
var row = $(this).jqGrid('getRowData',id);
if(row.userId==''){
content += " ";
}else{
content += " ";
}
content += " ";
content += " ";
if(row.investmentId!=''){
content += " ";
}
content += " ";
$(this).jqGrid('setRowData',id,{manager:content});
}
}
}).navGrid('#pager',{add: false, edit: false, del: false, search: false}).navButtonAdd('#pager',{
caption : "列选择",
title : "选择要显示的列",
onClickButton : function(){
$(this).jqGrid('columnChooser');
}
});
}