【问题标题】:JQGrid - How to insert HTML into grid footerJQGrid - 如何将 HTML 插入网格页脚
【发布时间】:2020-12-28 15:45:03
【问题描述】:

我目前正在使用免费的 jqGrid(版本 3.4.1),并且我已经构建了一个带有页脚的网格。这个网格有点特殊,因为列数是动态定义的(列数取决于我数据库中某些数据的数量)。

所以我正在尝试将图标(带有 HTLM 代码)插入到生成的每个动态列中。

我已经编写了在每一列上循环的代码部分,我可以插入纯文本,正如您在此屏幕截图中看到的那样。 Screenshot 我不想用一个图标(字体真棒或简单的引导字形图标)替换这个纯文本。

这是我目前的代码(只有网格的gridComplete功能,告诉我:

gridComplete: function() {
    var tabData = grid.jqGrid('getRowData')
    var footerCells = {"DONATEUR":"ACTION GLOBALES"};
    var footerCells2 = {}
    for (var i = 0; i < colModel.length-3; i++) {
        var indexCol = colModel[i+3].name
        footerCells[indexCol] = "test" // content of the cell here
    } 
    grid.jqGrid(
      "footerData",
      "set",
      footerCells,
      false
    )
    var $footerRow = grid.closest(".ui-jqgrid-bdiv").next(".ui-jqgrid-sdiv").find(".footrow");
    var $donateur = $footerRow.find('>td[aria-describedby="jqGrid-table-suivictrp_DONATEUR"]'),
    $montantDon = $footerRow.find('>td[aria-describedby="jqGrid-table-suivictrp_MT_DON"]'),
    width2 = $donateur.width() + $montantDon.outerWidth();
    $montantDon.css("display", "none");
    $donateur.attr("colspan", "2").width(width2);
}

【问题讨论】:

    标签: javascript jqgrid


    【解决方案1】:

    两个选项(取决于你)-

    1. 在 jqgrid 中呈现从服务器获取的纯文本 html 行
    Use/Set colmodel datatype = 'html'
    
    1. 如果您只想设置字体超赞的图标或引导图标,(例如 - https://free-jqgrid.github.io/getting-started/index.html#type_of_data_code
    You need to set the `iconSet` property in jqGrid options and `template` property in colmodel to use it.
    

    【讨论】:

    • 我使用了第二个选项,效果很好!!感谢您的帮助
    猜你喜欢
    • 2013-09-14
    • 1970-01-01
    • 2013-11-03
    • 1970-01-01
    • 2020-12-09
    • 2018-07-21
    • 1970-01-01
    • 2013-07-31
    • 1970-01-01
    相关资源
    最近更新 更多