jqgrid与oauth2.0

由于没找到原生jqgrid的加请求头方式。后来用ajax八数据加载到本地,请求头放到ajax中。代码如下:

$(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代码省略。

猜你喜欢

转载自www.cnblogs.com/yun3721/p/9080309.html