jQWidgets Forums

jQuery UI Widgets Forums Grid Uncaught Unspecified pivot aggregation function

Tagged: 

This topic contains 4 replies, has 2 voices, and was last updated by  Jwhitbread 3 years, 1 month ago.

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

  • Jwhitbread
    Participant

    Getting an error in console:
    “Uncaught Unspecified pivot aggregation function”

    Can’t figure out whats causing the issue comparing it to the example PivotGrid designer.

    Every time I try to drag a column or row in the designer it appears to freeze and crash which I assume is linked to this error.

            var source =
                {
                    localdata: data,
                    datatype: "array",
                    datafields:
                        [
                            { name: 'Prj_office', type: 'string' },
                            { name: 'Sum_timesheet_hours', type: 'string' },
                            { name: 'cost_centre', type: 'string' },
                            { name: 'customer_name', type: 'string' },
                            { name: 'department', type: 'string' },
                            { name: 'financial_month', type: 'string' },
                            { name: 'financial_year', type: 'string' },
                            { name: 'project_charge', type: 'string' },
                            { name: 'project_code', type: 'string' },
                            { name: 'project_description', type: 'string' },
                            { name: 'section', type: 'string' },
                            { name: 'user_name', type: 'string' },
                            { name: 'user_office', type: 'string' },
                            { name: 'year_week', type: 'string' }
                        ]
                };
            var dataAdapter = new $.jqx.dataAdapter(source);
            dataAdapter.dataBind();
            var pivotDataSource = new $.jqx.pivot(
                dataAdapter,
                {
                    pivotValuesOnRows: false,
                    rows: [
                        { dataField: 'user_name', width: 'auto'},
                        { dataField: 'cost_centre', width: 'auto'},
                        { dataField: 'financial_month', width: 'auto'},
                        { dataField: 'department', width: 'auto'},
                        { dataField: 'project_code', width: 'auto'},
                        { dataField: 'customer_name', width: 'auto'}],
                    columns: [{ dataField: 'year_week', width: 'auto'}],
                    values: [
                        { dataField: 'Sum_timesheet_hours', text: 'Hours' }
                    ]
                }
            );
            var localization = { 'var': 'Variance' };
            $('#divPivotGrid').jqxPivotGrid(
                {
                    localization: localization,
                    source: pivotDataSource,
                    treeStyleRows: false,
                    autoResize: false,
                    multipleSelectionEnabled: true
                });
            var pivotGridInstance = $('#divPivotGrid').jqxPivotGrid('getInstance');
            // create a pivot grid
            $('#divPivotGridDesigner').jqxPivotDesigner(
                {
                    type: 'pivotGrid',
                    target: pivotGridInstance
                });

    Martin
    Participant

    Hello Jwhitbread,

    We are not able to reproduce such error.
    Could you send us a jsFiddle example or update This one so we can inspect this further?
    Thank you!

    Best Regards,
    Martin Yotov

    jQWidgets team
    https://www.jqwidgets.com


    Jwhitbread
    Participant

    Hi Martin,

    Sorry for the late response I’ve returned to this and added to the JSFiddle.

    The Code

    Things to note:
    – Im running this on Edge
    – I still get a script error in the JSFiddle, and when I try to drag a row in the designer to the columns it freezes the label in the column.

    Here is what I put in the JS in case you can’t open the fiddle.

    $(document).ready(function() {
            var array = [{"user_name":"Jeff","year_week":"202205","project_code":"HOLDY","Sum_timesheet_hours":"37.50"},{"user_name":"Bob","year_week":"202202","project_code":"HOLDY","Sum_timesheet_hours":"24.75"},{"user_name":"Steve","year_week":"202206","project_code":"HOLDY","Sum_timesheet_hours":"37.50"},{"user_name":"Houdini ","year_week":"202207","project_code":"HOLDY","Sum_timesheet_hours":"16.50"},{"user_name":"Jack","year_week":"202209","project_code":"HOLDY","Sum_timesheet_hours":"16.50"},{"user_name":"Jill","year_week":"202202","project_code":"HOLDY","Sum_timesheet_hours":"8.25"},{"user_name":"Luigi","year_week":"202206","project_code":"HOLDY","Sum_timesheet_hours":"8.25"}];
            createPivotTable(array);
        });
    
        function createPivotTable(data){
            var source =
                {
                    localdata: data,
                    datatype: "array",
                    datafields:
                        [
                            { name: 'user_name', type: 'string' },
                            { name: 'year_week', type: 'number' },
                            { name: 'project_code', type: 'string' },
                            { name: 'Sum_timesheet_hours', type: 'string' }
                        ]
                };
            var dataAdapter = new $.jqx.dataAdapter(source);
            dataAdapter.dataBind();
            var pivotDataSource = new $.jqx.pivot(
                dataAdapter,
                {
                    pivotValuesOnRows: false,
                    rows: [
                        { dataField: 'user_name', width: 'auto'},
                        { dataField: 'year_week', width: 'auto'}],
                    columns: [{ dataField: 'project_code', width: 'auto'}],
                    values: [
                        { dataField: 'Sum_timesheet_hours', text: 'Hours' }
                    ]
                }
            );
            var localization = { 'var': 'Variance' };
            $('#divPivotGrid').jqxPivotGrid(
                {
                    localization: localization,
                    source: pivotDataSource,
                    treeStyleRows: false,
                    autoResize: false,
                    multipleSelectionEnabled: true
                });
            var pivotGridInstance = $('#divPivotGrid').jqxPivotGrid('getInstance');
            // create a pivot grid
            $('#divPivotGridDesigner').jqxPivotDesigner(
                {
                    type: 'pivotGrid',
                    target: pivotGridInstance
                });
        }

    Martin
    Participant

    Hello Jwhitbread,

    You have missed specifying the function property of the values objects, in your case Sum_timesheet_hours.
    I have added 'function': 'sum' and now it seems to be working fine. Here is the updated Example.

    Best Regards,
    Martin Yotov

    jQWidgets team
    https://www.jqwidgets.com


    Jwhitbread
    Participant

    Ah excellent yes that worked thank you!

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

You must be logged in to reply to this topic.