jQuery UI Widgets Forums Grid aggregates function for datetime

This topic contains 1 reply, has 2 voices, and was last updated by  Dimitar 9 years, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • aggregates function for datetime #74092

    sureshatpure
    Participant

    i have a column renderring in the grid which displays the date time in hh:mm:ss , now i have display the total for this column using aggregates: [‘sum’]
    is it possible ..?

     var source =
                    {
                        datatype: "json",
                        sortcolumn: 'date',
                        sortdirection: 'desc',
                        datafields: [
                            {name: 'empcode'},
                            {name: 'empname'},
                            {name: 'branch'},
                            {name: 'user_name'},
                            {name: 'month'},
                            {name: 'time_spent', type: 'datetime'},
                            {name: 'logout_time', type: 'datetime'},
                            {name: 'login_time', type: 'datetime'},
                            {name: 'date', type: 'datetime'},
                            {name: 'fin_yr', type: 'string'},
                            {name: 'jcode', type: 'string'}
    
                        ],
                        localdata: leadata,
                        pagenum: 0,
                        pagesize: 50,
                        pager: function (pagenum, pagesize, oldpagenum) {
                            // callback called when a page or page size is changed.
                        }
                    };
    
            var dataAdapter = new $.jqx.dataAdapter(source);
            $("#jqxgrid").jqxGrid(
                    {
                        width: '100%',
                        source: dataAdapter,
                        theme: theme,
                        sortable: true,
                        pageable: true,
                        columnsresize: true,
                        sortable: true,
                        showfilterrow: true,
                        filterable: true,
                        showstatusbar: true,
                        statusbarheight: 50,
                        showaggregates: true,
                        selectionmode: 'singlecell',
     
                        columns: [
                            {text: 'Emp Code', dataField: 'empcode', width: 70, hidden:true},
                            {text: 'Branch', dataField: 'branch', width: 100, cellsalign: 'left'},
                            {text: 'Username', dataField: 'user_name', width: 120},
                            {text: 'Login Time', dataField: 'login_time', cellsalign: 'left', width: 160, cellsformat: 'd', formatString: 'd'},
                            {text: 'Logout Time', dataField: 'logout_time', cellsalign: 'left', width: 160, cellsformat: 'd', formatString: 'd'},
                            {text: 'Time Spent', dataField: 'time_spent', cellsalign: 'left', width: 95, cellsformat: 'd', formatString: 'd',aggregates: ['sum'],
                                aggregatesrenderer: function (aggregates, column, element) {
                                    var renderstring = "<div class='jqx-widget-content jqx-widget-content-energyblue' style='float: left; width: 100%; height: 100%; '>";
                                    $.each(aggregates, function (key, value) {
                                        //  var name = key == 'min' ? 'Min' : 'Max';
                                        //  var color = key == 'max' ? 'green' : 'red';
    
                                        var name = key == 'sum' ? 'Σ' : 'sum';
                                        var color = key == 'sum' ? 'green' : 'red';
                                        renderstring += '<div style="color: ' + color + '; position: relative; margin: 0px; text-align: center; overflow: hidden;">'+ value + '</div>';
                                    });
                                    renderstring += "</div>";
                                    return renderstring;
                                }
    
                            },
                            {text: 'Date', dataField: 'date', cellsalign: 'left', width: 95, cellsformat: 'd',formatString: 'd'},
                            {text: 'Month', dataField: 'month', width: 50},
                            {text: 'Accnt-Year', dataField: 'fin_yr', width: 85,cellsalign: 'center'},
                            {text: 'JC Period', dataField: 'jcode', width: 85,cellsalign: 'center'}
    
                        ],
                        showtoolbar: true,
                        autoheight: true
             
                    });
            $('#jqxgrid').jqxGrid('renderaggregates');
    
    aggregates function for datetime #74119

    Dimitar
    Participant

    Hello sureshatpure,

    There is no built-in aggregates function that can accomplish your requirement. You would have to create a custom aggregate and calculate the total hours yourself.

    Best Regards,
    Dimitar

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

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

You must be logged in to reply to this topic.