如何将数据放在总“FooterRow”上?

时间:2014-03-11 17:44:04

标签: javascript jquery jqgrid

我正在使用 jqGrid 插件 4.6.0 jQuery 1.11.0 生成需要的报告总结中的总数。我只能生成按列分组的总数。 jqGrid有一个名为 footerrow 的属性,它应该是网格的摘要。

我需要将整个报告的总数放在FooterRow中,但我无法做到。

$("#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"} ];

1 个答案:

答案 0 :(得分:1)

交叉(和翻译)我的answer on SO-PT (written in Portuguese)


查看this example

基本上,您需要向loadComplete添加jqGrid功能,它将用于构建footerData

loadComplete: function () {
    var $self = $(this);
    var sumCanceled = $self.jqGrid("getCol", "cancelada", false, "sum");
    var sumReleased = $self.jqGrid("getCol", "liberada", false, "sum");
    var sumDenied = $self.jqGrid("getCol", "negada", false, "sum");
    var sumPending = $self.jqGrid("getCol", "pendente", false, "sum");

    $self.jqGrid("footerData", "set", {
        loginMedico: "Total:", 
        cancelada: sumCanceled, 
        liberada: sumReleased,  
        negada: sumDenied,
        pendente: sumPending
    });
}

来源:getting the sum using footerdata on jqgrid