How to export inside the subGrid?

Asked

Viewed 174 times

5

Information: I’m using the jqGrid(4.54), and also implemented the SubGrid, after opening the SubGrid, it is necessary to export the contents of the open table.

Question: There is a way to implement a button or link within the SubGrid?

See below the code of mine SubGrid:

 var subgrid_table_id;
       subgrid_table_id = subgrid_id+"_t";
       jQuery("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='paginacaoSub'></div>");
       jQuery("#"+subgrid_table_id).jqGrid({
          url: urlRelatorioInterno,
          datatype: 'json',
          mtype: 'POST',
          colModel: [
            {name:"dataHora", index:"dataHora", jsonmap:"dataHora", label:"Data e Hora", sortable: true, sorttype: "date"},
            {name:"tipoSolicitacao",index:"tipoSolicitacao",jsonmap:"tipoSolicitacao",label:"Tipo Solicitacao", sortable: true, sorttype: "int"},
            {name:"statusSolicitacao",index:"statusSolicitacao",jsonmap:"statusSolicitacao",label:"Status Solicitacao",  sortable: true, sorttype: "text"},
            {name:"numeroSolicitacao",index:"numeroSolicitacao",jsonmap:"numeroSolicitacao",label:"Numero Solicitacao",  sortable: true, sorttype: "int"},           
            {name:"numeroCartao",index:"numeroCartao",jsonmap:"numeroCartao",label:"Numero Cartao",  sortable: true, sorttype: "int"},
            {name:"nomeSegurado",index:"nomeSegurado",jsonmap:"nomeSegurado",label:"Nome Segurado",  sortable: true, sorttype: "text"},
            {name:"codigoReferenciado",index:"codigoReferenciado",jsonmap:"codigoReferenciado",label:"Codigo Referenciado",  sortable: true, sorttype: "int"},
            {name:"nomeReferenciado",index:"nomeReferenciado",jsonmap:"nomeReferenciado",label:"Nome Referenciado",  sortable: true, sorttype: "text"},
            {name:"senha",index:"senha",jsonmap:"senha",label:"Senha",  sortable: true, sorttype: "text"},           
            {name:"canalSolicitacao",index:"canalSolicitacao",jsonmap:"canalSolicitacao",label:"Canal Solicitacao",  sortable: true, sorttype: "int"}],

          pager: "#paginacaoSub",
          scroll: 1,
          width: 1100,
          height: 240,
          rowNum:10,
          rowList: true,
          loadonce:true
       });
  • 1

    Your question is how to implement an export function within the subgrid or how to add a button within the subgrid?

  • 1

    I think it would be like putting a/link button inside that subGrid. I would add a column in JSON with the link, the problem would be to find the filter parameters.

  • In addition, it is necessary to insert an export to excel and pdf button in the contents opened by subGrid. I wonder if there is any simple way to implement this export.

1 answer

2


Guys I found an easy way to insert the buttons in the subgrid. jqGrid already provides a mode to insert via a jqGrid "navButtonAdd" function. Below is the subGrid code next to the button code.

var urlTipoSolicitacao = "?filtro.tipoSolicitacao="+$('#respostaRelatorio').jqGrid('getRowData', row_id).tipoSolicitacao;
       var subgrid_table_id;
       subgrid_table_id = subgrid_id+"_t";
       jQuery("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='paginacaoSub'></div>");
       jQuery("#"+subgrid_table_id).jqGrid({
          url: urlRelatorioInterno + urlTipoSolicitacao,
          datatype: 'json',
          mtype: 'POST',
          colModel: [
            {name:"dataHora", index:"dataHora", jsonmap:"dataHora", label:"Data e Hora", sortable: true, sorttype: "date"},
            {name:"tipoSolicitacao",index:"tipoSolicitacao",jsonmap:"tipoSolicitacao",label:"Tipo Solicitacao", sortable: true, sorttype: "int"},
            {name:"statusSolicitacao",index:"statusSolicitacao",jsonmap:"statusSolicitacao",label:"Status Solicitacao",  sortable: true, sorttype: "text"},
            {name:"numeroSolicitacao",index:"numeroSolicitacao",jsonmap:"numeroSolicitacao",label:"Numero Solicitacao",  sortable: true, sorttype: "int"},           
            {name:"numeroCartao",index:"numeroCartao",jsonmap:"numeroCartao",label:"Numero Cartao",  sortable: true, sorttype: "int"},
            {name:"nomeSegurado",index:"nomeSegurado",jsonmap:"nomeSegurado",label:"Nome Segurado",  sortable: true, sorttype: "text"},
            {name:"codigoReferenciado",index:"codigoReferenciado",jsonmap:"codigoReferenciado",label:"Codigo Referenciado",  sortable: true, sorttype: "int"},
            {name:"nomeReferenciado",index:"nomeReferenciado",jsonmap:"nomeReferenciado",label:"Nome Referenciado",  sortable: true, sorttype: "text"},
            {name:"senha",index:"senha",jsonmap:"senha",label:"Senha",  sortable: true, sorttype: "text"},           
            {name:"canalSolicitacao",index:"canalSolicitacao",jsonmap:"canalSolicitacao",label:"Canal Solicitacao",  sortable: true, sorttype: "int"}],
          pager: "#paginacaoSub",
          scroll: 1,
          width: 1100,
          height: 135,
          rowNum:5,
          rowList: true,
          loadonce:true
         }).jqGrid('navGrid', '#paginacaoSub', {
                           add: false,
                           edit: false,
                           del : false,
                           search: false,
                           refresh: false
                             }).jqGrid('navButtonAdd', '#paginacaoSub',{ 
                           caption: "Exportar Excel",
                           onClickButton: function(){ 
                                window.location.href = urlExportarExcelInterno + urlTipoSolicitacao;
                               }, 
                           position: "first"
                             }).jqGrid('navButtonAdd', '#paginacaoSub',{
                           caption: "Exportar PDF",
                           onClickButton: function(){ 
                               window.location.href = urlExportarPdfInterno + urlTipoSolicitacao;
                                   }, 
                           position: "first"

                             });
                      };

Browser other questions tagged

You are not signed in. Login or sign up in order to post.