How to bring the total of each column in the FooterRow of a jqGrid?

11

I'm using the jqGrid (4.6.0) property with jQuery (1.11.0) , but I was only able to generate the total per column and not That's what I want, I'd like the grand total. The jqGrid contains the grouping property that contains the grouping that would be the Grid footer row (table). Does anyone know how to bring totals into footerrow ?

The properties I'm using in Grid :

$("#respostaRelatorio").jqGrid({
    url: urlRelatorio + "?" + dadosRelatorio,
    colModel: modeloColunas,
    mtype: "POST",
    altRows: true,
    datatype: "json",
    loadonce: true,
    height: "auto",
    width: 1130,
    rowNum: 10,
    rowList: [ 10, 20, 30, 40, 50 ],
    viewrecords: true,
    pager: "#paginacao",
    sortorder: "asc",
    shrinkToFit: false,
    headertitles: true,
    loadui: "disable",
    rownumbers: true,
    autoencode: true,
    caption: "Resultados encontrados",
    deselectAfterSort: true,
    gridview: true,
    idPrefix: "id",
    rowTotal: 4000,
    sortable: true,
    toppager: true,
    resizable: true,
    grouping: true,
    groupingView: {
        groupField: [ 'loginMedico' ],
        groupCollapse: false,
        groupOrder: [ 'asc' ],
        groupSummary: [ true ],
        groupDataSorted: true
    },
    footerrow: true,
    userDataOnFooter: true
});

var modeloColunas = [
    { name: "loginMedico", index: "loginMedico", jsonmap: "loginMedico", label: "Login Médico", sortable: true, sorttype: "text", summaryType: "count", summaryTpl: "total" },
    { name: "nomeMedico", index: "nomeMedico", jsonmap: "nomeMedico", label: "Nome do Médico", sortable: true, sorttype: "text" },
    { name: "perfilMedico", index: "perfilMedico", jsonmap: "perfilMedico", label: "Perfil Médico", sortable: true, sorttype: "text"},
    { name: "tipoSolicitacao", index: "tipoSolicitacao", jsonmap: "tipoSolicitacao", label: "Tipo da Solicitação", sortable: true, sorttype: "text" },
    { name: "cancelada", index: "cancelada", jsonmap: "cancelada", label: "Cancelada", sortable: true, sorttype: "int" },
    { name: "liberada", index: "liberada", jsonmap: "liberada", label: "Liberada", sortable: true, sorttype: "int", summaryType: "sum" },
    { name: "negada", index: "negada", jsonmap: "negada", label: "Negada", sortable: true, sorttype: "int", summaryType: "sum" },
    { name: "pendente", index: "pendente", jsonmap: "pendente", label: "Pendente", sortable: true, sorttype: "int", summaryType: "sum" },
    { name: "total", index: "total", jsonmap: "total", label: "Total", sortable: true, sorttype: "int", summaryTpl: "total"} ];

The image of my Grid , note that footerrow appears empty:

    
asked by anonymous 11.03.2014 / 19:37

1 answer

8

Take a look at in this example .

You should basically add a loadComplete function to jqGrid to feed the summary line:

loadComplete: function () {
    var $self = $(this);
    var somaCanceladas = $self.jqGrid("getCol", "cancelada", false, "sum");
    var somaLiberadas = $self.jqGrid("getCol", "liberada", false, "sum");
    var somaNegadas = $self.jqGrid("getCol", "negada", false, "sum");
    var somaPendentes = $self.jqGrid("getCol", "pendente", false, "sum");

    $self.jqGrid("footerData", "set", {
        loginMedico: "Total:", 
        cancelada: somaCanceladas, 
        liberada: somaLiberadas, 
        negada: somaNegadas,
        pendente: somaPendentes 
    });
}

Source: SOE - getting the sum using footerdata on jqgrid

    
15.03.2014 / 21:30