jQuery UI Widgets Forums Grid Aggregates with columngroup

This topic contains 2 replies, has 2 voices, and was last updated by  Gerardo Manrique 9 years, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Aggregates with columngroup #70253

    Gerardo Manrique
    Participant

    Hi there!

    Is it possible to set Aggregates for Columngroups?
    I have Aggregates for Columns and some of those Columns belong to their respective Columngroups, but I don´t know how to get the Aggregates for the Columngroups below (or over) the Column Aggregates.
    Thanks in advance.
    Here’s my code:

    
    // Cuadrícula de Elecciones
    
    var fuenteDeDatosElecciones = 
    {
        datatype: "xml",
        datafields: 
        [
             { name: 'Numero', type: 'int' }
            ,{ name: 'Representacion' }
    		,{ name: 'CU-P', type: 'int' }
    		,{ name: 'CU-I', type: 'int' }
    		,{ name: 'CU-A', type: 'int' }
    		,{ name: 'CAACFMI-P', type: 'int' }
    		,{ name: 'CAACFMI-I', type: 'int' }
    		,{ name: 'CAACFMI-A', type: 'int' }
    		,{ name: 'CAAHYA-P', type: 'int' }
    		,{ name: 'CAAHYA-I', type: 'int' }
    		,{ name: 'CAAHYA-A', type: 'int' }
    		,{ name: 'CT-P', type: 'int' }
    		,{ name: 'CT-I', type: 'int' }
    		,{ name: 'CT-A', type: 'int' }	                
            ,{ name: 'Total', type: 'int' }
        ],
        root: "TablaElectoral",
        record: "EleccionesPorRepresentacion",
        id: 'Numero',
        url: '/sise/controladores/elecciones/reportes/controlador-de-reportes.php?obtieneTablaElectoral&idProceso='+$('#listaProceso').val()
    };
    
    var adaptadorDeDatosElecciones = new $.jqx.dataAdapter(fuenteDeDatosElecciones);
    
    var grupos =
    [
    
    	 { text: 'CU', name: 'CU', align: 'center', aggregates: ['sum'] }
    	,{ text: 'CAACFMI', name: 'CAACFMI', align: 'center', aggregates: ['sum'] }
    	,{ text: 'CAAHYA', name: 'CAAHYA', align: 'center', aggregates: ['sum'] }
    	,{ text: 'CT', name: 'CT', align: 'center', aggregates: ['sum'] }		    
    ];
    
    var columnas = 
    [
    	 { text: 'N°', datafield: 'Numero' ,width: 35, align: 'center', cellsalign: 'center' }
    	,{ text: 'Representación', datafield: 'Representacion' , width: 180, align: 'center', aggregates: [{'Total':function(conteo){ return conteo + 1; } }]}
    	,{ text: 'P',datafield: 'CU-P',columngroup: 'CU',cellsalign: 'center',align: 'center',aggregates: ['sum'],aggregatesrenderer: formateaAgregados,width: 35 }
    	,{ text: 'I',datafield: 'CU-I',columngroup: 'CU',cellsalign: 'center',align: 'center',aggregates: ['sum'],aggregatesrenderer: formateaAgregados,width: 35 }
    	,{ text: 'A',datafield: 'CU-A',columngroup: 'CU',cellsalign: 'center',align: 'center',aggregates: ['sum'],aggregatesrenderer: formateaAgregados,width: 35 }
    	,{ text: 'P',datafield: 'CAACFMI-P',columngroup: 'CAACFMI',cellsalign: 'center',align: 'center',aggregates: ['sum'],aggregatesrenderer: formateaAgregados,width: 35 }
    	,{ text: 'I',datafield: 'CAACFMI-I',columngroup: 'CAACFMI',cellsalign: 'center',align: 'center',aggregates: ['sum'],aggregatesrenderer: formateaAgregados,width: 35 }
    	,{ text: 'A',datafield: 'CAACFMI-A',columngroup: 'CAACFMI',cellsalign: 'center',align: 'center',aggregates: ['sum'],aggregatesrenderer: formateaAgregados,width: 35 }
    	,{ text: 'P',datafield: 'CAAHYA-P',columngroup: 'CAAHYA',cellsalign: 'center',align: 'center',aggregates: ['sum'],aggregatesrenderer: formateaAgregados,width: 35 }
    	,{ text: 'I',datafield: 'CAAHYA-I',columngroup: 'CAAHYA',cellsalign: 'center',align: 'center',aggregates: ['sum'],aggregatesrenderer: formateaAgregados,width: 35 }
    	,{ text: 'A',datafield: 'CAAHYA-A',columngroup: 'CAAHYA',cellsalign: 'center',align: 'center',aggregates: ['sum'],aggregatesrenderer: formateaAgregados,width: 35 }
    	,{ text: 'P',datafield: 'CT-P',columngroup: 'CT',cellsalign: 'center',align: 'center',aggregates: ['sum'],aggregatesrenderer: formateaAgregados,width: 35 }
    	,{ text: 'I',datafield: 'CT-I',columngroup: 'CT',cellsalign: 'center',align: 'center',aggregates: ['sum'],aggregatesrenderer: formateaAgregados,width: 35 }
    	,{ text: 'A',datafield: 'CT-A',columngroup: 'CT',cellsalign: 'center',align: 'center',aggregates: ['sum'],aggregatesrenderer: formateaAgregados,width: 35 }				
    	,
    	{ 
    		text: 'Total'
    		, datafield: 'Total'
    		, width: 60
    		, cellsalign: 'center'
    		, align: 'center'
    		, aggregates: ['sum'] 
    		, aggregatesrenderer: formateaAgregados
    
    	}
    ];
    
    function formateaAgregados(agregados, column, element) 
    {
    	var renderstring = "<div style='float: left; width: 100%; height: 100%; '>";
    	$.each
    	(
    		agregados
    		,function (key, value) 
    		{
    			renderstring += '<div style="position: relative; margin: 4px; text-align: center; overflow: hidden;"><b>' + value + '</b></div>';
    		}
    	);
    	renderstring += "</div>";
    	return renderstring;
    }
    
    function crearBarraDeHerramientas(barra)
    {
    	var contenedor = $("<div style='margin: 5px;'></div>");
        barra.append(contenedor);
        contenedor.append('<input id="botonExportar" type="button" value="Exportar" class="boton" />');
        $('.boton').jqxButton({theme: 'cvic'});
    	$('#botonExportar').on
    	(
    		'click'
    		,function () 
    		{
    			$('#cuadriculaElecciones').jqxGrid('exportdata', 'xls', 'TablaElectoral');
        	}
        );
    }
    
    $('#cuadriculaElecciones').jqxGrid
    ({
         width: 974
        ,source: adaptadorDeDatosElecciones
        ,columns: columnas
        ,rendertoolbar: crearBarraDeHerramientas
        ,autoheight: true
        ,columnsresize: true
        ,enabletooltips: true
        ,sortable: true
        ,filterable: true
        ,showfilterrow: true
        ,showaggregates: true
        ,showtoolbar: true
        ,showstatusbar: true
        ,statusbarheight: 50
        ,theme: 'cvic'
        ,altrows: true
        ,columngroups: grupos
    });
    
    Aggregates with columngroup #70273

    Dimitar
    Participant

    Hi Gerardo Manrique,

    Aggregates are only available per column. However, you may create a custom statusbar, where to display whatever information you like.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Aggregates with columngroup #70312

    Gerardo Manrique
    Participant

    Thanks Dimitar.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.