jQWidgets Forums

jQuery UI Widgets Forums Grid Calculating Total Hours based on Date using groupsrenderer Issue

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 11 years, 3 months ago.

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

  • Pankaj Srivastava
    Participant

    Hello Team,

    I am using Jqxgrid groupsrenderer my requirement is i just wanted to calculate hours based grouping of Date,everything is working fine only but date is showing Date:NaN (22 totalhours) and also if i delete date and drag and drop again then hours is showing undefined I find code below which i am using.

    var groupsrenderer = function (text, group, expanded, data) {
    debugger;
    group = group.getDate() + “/” + (group.getMonth() + 1) + “/” + group.getFullYear();
    if (data.groupcolumn.datafield == ‘DateOfEntry’ || data.groupcolumn.datafield == ‘Hours’) {
    var number = dataAdapter.formatNumber(group, data.groupcolumn.cellsformat);
    var text = data.groupcolumn.text + ‘: ‘ + number;
    if (data.subItems.length > 0) {
    data.groupcolumn.datafield = ‘Hours’
    var aggregate = this.getcolumnaggregateddata(data.groupcolumn.datafield, [‘sum’], true, data.subItems);
    }
    else {
    var rows = new Array();
    var getRows = function (group, rows) {
    if (group.subGroups.length > 0) {
    for (var i = 0; i < group.subGroups.length; i++) {
    getRows(group.subGroups[i], rows);
    }
    }
    else {
    for (var i = 0; i < group.subItems.length; i++) {
    rows.push(group.subItems[i]);
    }
    }
    }
    getRows(data, rows);
    var aggregate = this.getcolumnaggregateddata(data.groupcolumn.datafield, [‘sum’], true, rows);
    }

    return ‘<div class=”jqx-grid-groups-row” style=”position: absolute;”><span>’ + text + ‘, </span>’ + ‘<span class=”jqx-grid-groups-row-details”>’ + “Total” + ‘ (‘ + aggregate.sum + ‘)’ + ‘</span></div>’;
    }

    }

    $(‘#jqxPeriodGrid’).jqxGrid(
    {
    width: ‘100%’,
    source: projectSource,
    pageable: false,
    editable: false,
    autoheight: true,
    theme: window.themes,
    sortable: true,
    columnsresize: true,
    groupsrenderer: groupsrenderer,
    altrows: true,
    groupable: true,
    ready: function () {
    $(“#jqxPeriodGrid”).jqxGrid(‘selectrow’, 0);
    $(‘#jqxPeriodGrid’).jqxGrid(‘focus’);
    },
    columns: [

    {
    text: ‘In’, datafield: ‘TimeIn’, width: ‘10%’, cellsformat: “t”
    },
    {
    text: ‘Out’, datafield: ‘TimeOut’, width: ‘10%’, cellsformat: “t”
    },
    { text: ‘Hours’, datafield: ‘Hours’, width: ‘10%’ },
    {
    text: ‘Project’, datafield: ‘Title’, width: ‘22%’
    },
    {
    text: ‘Billable’, datafield: ‘Billable’, width: ‘6%’

    },
    { text: ‘Comments’, datafield: ‘Comments’, width: ‘30%’ },
    { text: ‘Date’, datafield: ‘DateOfEntry’, width: ‘12%’, cellsformat: “dd/MM/yyyy” },
    ],
    groups: [‘DateOfEntry’]
    });
    $(‘#vpwindow’).jqxWindow(‘open’);
    },
    error: function (xhr) {
    alert(xhr.status + ‘: ‘ + xhr.statusText);
    console.log(xhr.status + ‘: ‘ + xhr.statusText);
    }
    });

    }


    Peter Stoev
    Keymaster

    Hi Pankaj,

    You cannot use the aggregating function for Date values. You can them for Numbers. If you want to aggregate some parts of Date values, then you should manually implement such aggregating functions.

    Best Regards,
    Peter Stoev

    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.