jQWidgets Forums

jQuery UI Widgets Forums Grid How to get average value.

Tagged: 

This topic contains 4 replies, has 2 voices, and was last updated by  Mpod Schuzatcky 10 years ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • How to get average value. #72721

    Mpod Schuzatcky
    Participant

    Hi Mates,

    I’ve edited some codeigniter code, there is view that show data in grid using jqgrid. like picture below.
    Grid view
    And here the code to show sum value :

    {
    text: ‘Akurasi Stok WIP Keramik’,
    align: ‘center’,
    datafield: ‘akurasi’,
    filterable: false,
    cellsformat: ‘n’,
    cellsalign: ‘right’,
    width: 120,
    aggregates: [
    {
    ‘total’: function (aggregatedValue, currentValue, column, record) {
    return aggregatedValue + currentValue;
    }
    },
    ],
    aggregatesrenderer: function (aggregates, column, element, summaryData) {
    var renderstring = “<div style=’padding:5px’>”;
    var total = aggregates.total;
    renderstring += total;
    renderstring += “</div>”;
    return renderstring;
    }
    },

    The questions is, how to get average value? because im not familiar with jqgrid.

    Thanks, Fadli.

    How to get average value. #72723

    Mariya
    Participant

    Hi mpod555,

    Thank you for your interest in jqxGrid. Take a look at the provided example at: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/aggregatesrenderer.htm?arctic If you have any further questions do not hesitate to contact us.

    Best Wishes,
    Mariya

    jQWidgets Team
    http://www.jqwidgets.com

    How to get average value. #72728

    Mpod Schuzatcky
    Participant

    Thanx for fast respons.
    I’ve seen the demo before, but still confused how to combine in this code below.

    {
    text: ‘Akurasi Stok WIP Keramik’,
    align: ‘center’,
    datafield: ‘akurasi’,
    filterable: false,
    cellsformat: ‘n’,
    cellsalign: ‘right’,
    width: 120,
    aggregates: [
    {
    ‘total’: function (aggregatedValue, currentValue, column, record) {
    return aggregatedValue + currentValue;
    }
    },
    ],
    aggregatesrenderer: function (aggregates, column, element, summaryData) {
    var renderstring = “<div style=’padding:5px’>”;
    var total = aggregates.total;
    renderstring += total;
    renderstring += “</div>”;
    return renderstring;
    }
    },

    can u help how to add code (what i must add) to get average value replace sum value.

    How to get average value. #72737

    Mariya
    Participant

    Hi mpod555,

    Can you please provide us with an example using jsFiddle?

    Best Wishes,
    Mariya

    jQWidgets Team
    http://www.jqwidgets.com

    How to get average value. #72780

    Mpod Schuzatcky
    Participant

    [SOLVED]
    Finally, i get what i need, thnx Mariya for your inspired reply…. nice to meet u btw…
    View

    I’m modified some code here :

    {
    text: ‘Akurasi Stok WIP Keramik’,
    align: ‘center’,
    datafield: ‘akurasi’,
    filterable: false,
    cellsalign: ‘right’,
    width: 120,
    aggregates: [‘avg’],
    aggregatesrenderer: function (aggregates, column, element, summaryData) {
    var renderstring = “<div style=’padding:5px’>Rerata: “;
    var total = aggregates.avg;
    renderstring += total.toFixed(2);;
    renderstring += ” %</div>”;
    return renderstring;
    }
    },

    Note : How to closed this thread as closed / solved?

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

You must be logged in to reply to this topic.