【问题标题】:jQgrid not loading the custom userData on loadCompletejQgrid没有在loadComplete上加载自定义userData
【发布时间】:2021-12-06 10:43:24
【问题描述】:

我正在尝试从存储在 json 中的服务器发送的一些自定义数据与表数据一起存储。我发送的 JSON 就是这个

{"total":1,"page":1,"records":1,"userdata":{"aaa":"bbb"},"rows":[{"id":0,"cell":["ampolla","1"]}]}

我正在尝试使用这个在 loadComplete 事件中获取这个用户数据

loadComplete: function() {          
    console.log(jQuery("#gridDataGraphic").getGridParam('userData'));
},

根据其他帖子,我认为我正在使用“userdata”正确构建 json 并使用“userData”进行处理,所以我不知道我的问题出在哪里。

整个 jQgrid 的定义就是这个(以防万一有人需要):

$("#${gridDataGraphic}").jqGrid({
    url: gridUrl,
    postData: gridPostData,
    datatype: "json",
    height: "auto",
    autoencode: true,
    shrinkToFit: true,                   
    autowidth: true,        
    multiselect:false,
    forceFit:true,              
    loadui: '',
    loadtext: '',
    altRows: true,
    altclass: 'ui-priority-altRow',
    colNames:["<bean:message key='label.category'/>",
              "<bean:message key='label.value'/>"
              ],
    colModel:[
            {name:'${dataGraphicColumnCategory}', index:'${dataGraphicColumnCategory}', resizable:false, editable:false, search:false, sortable:true},
            {name:'${dataGraphicColumnValue}', index:'${dataGraphicColumnValue}', resizable:false, editable:false, search:false, sortable:true}
            ],
    rowNum: rowNums,
    gridview: true,
    mtype: "POST",                  
    pager: jQuery('#${pagerDataGraphic}'),
    sortname: "${lastOrderName}",
    sortorder: "${lastSortOrder}",
    page: "${ReportGenerationForm.currentPage}",
    sidx: "${param.sidx}",
    sord: "${param.sord}",
    viewrecords: true,
    onCellSelect: function(rowid,iCol,cellcontent) {},      
    pginput:true,
    loadError: function (xhr, status, error){
        showErrorDialog("<bean:message key='system.error.body'/>: " + error);
    },
    recordpos:"right",
    pagerpos:"center",
    loadComplete: function() {
        console.log(jQuery("#gridDataGraphic").getGridParam('userData'));
    },
    gridComplete: function() {},
    onSortCol: function (index, columnIndex, sortOrder) {
        $("#${gridDataGraphic}").trigger('reloadGrid');                                             
    }
});

现在网格已完美加载并显示行;但控制台日志返回 undefined :(

非常感谢您提供的任何帮助。

【问题讨论】:

    标签: json ajax jqgrid


    【解决方案1】:

    我认为您将不存在的网格(可能)称为替换:

    loadComplete: function() {
        console.log(jQuery("#gridDataGraphic").getGridParam('userData'));
    },
    

    loadComplete: function() {
        console.log(jQuery("#${gridDataGraphic}").getGridParam('userData'));
    },
    

    【讨论】:

    • 谢谢!现在正在工作:)
    • 谢谢。很高兴能提供帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-04
    • 2012-01-23
    • 1970-01-01
    • 1970-01-01
    • 2012-11-25
    • 1970-01-01
    相关资源
    最近更新 更多