jqgrid與oauth2.0

因爲沒找到原生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

相關文章
相關標籤/搜索