因为没找到原生jqgrid的加请求头方式。后来用ajax八数据加载到本地,请求头放到ajax中。代码以下:html
$(function () { $.jgrid.defaults.styleUI = 'Bootstrap'; $("#grid").jqGrid({ datatype: "local", height: 600,//高度,表格高度。可为数值、百分比或'auto' autowidth: true,//自动宽 rowNum: 20, rowList: [20, 50, 100], colNames: ['ID', '操做', '登陆帐号', '用户名', '建立者', '建立时间', '密码'], colModel: [ {name: 'id', key: true, hidden: true}, {name: 'act', width: 70, sortable: false, formatter: operate}, {name: 'username', index: 'username', editable: true, editoptions: {size: 10}, width: 100}, {name: 'name', index: 'name', editable: true, editoptions: {size: 10}, width: 150}, {name: 'creatorId', index: 'creatorId', width: 150}, {name: 'createTime', index: 'createTime', width: 150}, {name: 'password', hidden: true, editable: true, editoptions: {size: 10}} ], rownumbers: true, altRows: true, sortname: 'id', sortorder: 'desc', pager: "#pager", viewrecords: true }); var localData = {}; doAjax(_URL + "/user", null, "GET", function (xhr) { xhr.setRequestHeader("token", getToken()); }, function (data) { localData.data = data.result.data; localData.records = data.result.total; }); })
html代码省略。ajax