JQGrid - How to insert HTML into grid footer

Viewed 152

I'm currently working with free jqGrid (version 3.4.1) and i have built a grid with a footer. This grid is a bit special because the number of column is dynamically defined (number of columns depend on the number of some datas in my database).

So i'm trying to insert icon (with HTLM code) into each dynamic columns that are generated.

I have already wrote the code part to loop on each columns and i can insert plain text as you can see on this screenshot. Screenshot What i wan't is to replace this plain text by an icon (font awesome or simple bootstrap glyphicon).

Here is the code i have currently (only the gridComplete function of the grid, let me know:

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);
}
1 Answers

Two options (depending upon you) -

  1. Rendering the plain text html, which you fetch from server, in jqgrid row
Use/Set colmodel datatype = 'html'
  1. If you just want to set the font-awesome icons or bootstrap icons, (Example - 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.
Related