Show table fields jQWidgets in excel file

0

Hello this time I have this function (initGrid) to load a table with jQWidgets, the loading of the table is done correctly ....

function initGrid(cb){
    var alto = window.innerHeight;
    alto -= 250;      
    $grid.jqxGrid({
        theme: theme,
        width: '100%',
        height: alto,
        altRows: true,
        filterable: true,
        columnsresize: true,
        showfilterrow: true,
        showstatusbar: true,
        statusbarheight: 30,
        showaggregates: true,
        columns: [
          { text: 'campo 1', datafield: 'campo 1',align: 'center', width: '10%',cellsalign: 'left', filtertype: 'checkedlist', pinned: true },
          { text: 'campo 2',datafield: 'campo 2',align: 'center', width: '10%', cellsalign: 'left', filtertype: 'checkedlist', pinned: true},
          { text: 'campo 3',datafield: 'campo 3',align: 'center', width: '10%', cellsalign: 'left', filtertype: 'checkedlist', pinned: true},
          { text: 'campo 4', datafield: 'campo 4',  align: 'center', width: '10%', cellsalign: 'left', filtertype: 'checkedlist',aggregates: [obj_CountTotal], pinned: true },
          { text: 'Campo 5', datafield: 'campo 5',  align: 'center', width: 100, cellsalign: 'center', aggregates: ['sum'] },
          { text: 'Campo 6', datafield: 'campo6',  align: 'center', width: 150, cellsalign: 'right', cellsformat: 'c2', aggregates: ['sum'], filterable:false },
          { text: 'Campo 7', datafield: 'campo7',  align: 'center', width: 150, cellsalign: 'right', cellsformat: 'c2', aggregates: ['sum'], filterable:false },
          { text: 'Campo 8', datafield: 'campo8',  align: 'center', width: 150, cellsalign: 'right', cellsformat: 'c2', aggregates: ['sum'], filterable:false },
          { text: 'campo 9', datafield: 'campo9',  align: 'center', width: 150, cellsalign: 'right', cellsformat: 'c2', aggregates: ['sum'], filterable:false },
          { text: 'campo 10', datafield: 'campo10',  align: 'center', width: 100, cellsalign: 'center', aggregates: ['sum'] },
          { text: 'campo 11', datafield: 'campo11',  align: 'center', width: 150, cellsalign: 'right', cellsformat: 'c2', aggregates: ['sum'], filterable:false },
          { text: '% campo porcentaje', datafield: 'porc',  align: 'center', width: 150, cellsalign: 'right', cellsformat: 'p2', aggregatesrenderer:fnc_PorcColocacion },
          { text: 'campo 13', datafield: 'campo13',  align: 'center', width: 100, cellsalign: 'center', aggregates: ['sum'] },
          { text: 'campo 14', datafield: 'campo14',  align: 'center', width: 150, cellsalign: 'right', cellsformat: 'c2', aggregates: ['sum'], filterable:false },
          { text: '% campo porcentaje 2', datafield: 'campo15',  align: 'center', width: 150, cellsalign: 'right', cellsformat: 'p1', aggregatesrenderer:fnc_PorcMalas },
          { text: 'campo 16', datafield: 'campo16',  align: 'center', width: 150, cellsalign: 'right', cellsformat: 'c2', aggregates: ['sum'], filterable:false },
          { text: 'campo 17', datafield: 'campo17',  align: 'center', width: 150, cellsalign: 'right', cellsformat: 'c2', aggregates: ['sum'], filterable:false },
          { text: 'campo 18', datafield: 'campo18',  align: 'center', width: 150, cellsalign: 'right', cellsformat: 'c2', aggregates: ['sum'], filterable:false },              
          { text: 'campo 19', datafield: 'campo19',  align: 'center', width: 150, cellsalign: 'right', cellsformat: 'c2', aggregates: ['sum'], filterable:false }

        ]
    });
    $grid.jqxGrid('localizestrings', localizationobj);
    $grid.on('rowselect', function (event){ 
        //index_selected = event.args.rowindex;      
        //row_selected = event.args.row;
    });  
    cb();
}

This same table I export to an excel file with this function

function initExportExcel(){      
    $xlsexport.jqxButton({theme:theme, disabled: true, width:150, height:30});
    var exportInfo;
    $xlsexport.click(function () {
      var now = $fecha.val('date');
      var curr_date = now.getDate();
      var curr_month = now.getMonth() + 1; //Months are zero based
      var curr_year = now.getFullYear();
      if (curr_month   < 10) {curr_month   = "0"+curr_month;}
      if (curr_date < 10) {curr_date = "0"+curr_date;}
      var curr_ts = curr_year + "-" + curr_month + "-" + curr_date;
      now = null;
      var filename = 'Semana '+ curr_ts + '.xls'; 
      exportInfo = $grid.jqxGrid('exportData', 'xls');
      downloadFile(exportInfo, filename);            
    });
}

The problem is that when exporting the table the fields % field percentage and % field percentage 2 They appear empty without information Note: in these two fields the calculation is made in percentage and the rest of the fields show sums Any idea why that behavior and some solution ???

    
asked by Karime 23.08.2018 в 01:29
source

0 answers