Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
830
Right-aligning numeric cell values in igPivotGrid
posted

Hi,

We are using igPivotGrid, we need to right align the numeric columns and left align text columns.

Please suggest a method to do so.

Thanks.

Parents
No Data
Reply
  • 23953
    Verified Answer
    Offline posted

    Hello,

    You can do this in the dataRendering event by adding columnCssClass to the respective numeric column.

    Here is a code snippet.

    $("#pivotGrid").on("iggriddatarendering", function (evt, ui) {

    // return if the column collection is not generated yet

    if (ui.owner.options.columns && ui.owner.options.columns.length === 0) {

    return;

    }

    for (var i = 0; i < ui.owner.options.columns.length; i++) {

    if (ui.owner.dataSource.data()[0] && $.isNumeric(ui.owner.dataSource.data()[0][ui.owner.options.columns[i].key])) {

    ui.owner.options.columns[i].columnCssClass = "right-align";

    }

    }

    });

    This code snippet analyses the data in the first record of the grid data source and adds a "right-align" CSS class to the column.
    I'm attaching a complete sample for your reference.

    Best regards,
    Martin Pavlov
    Infragistics, Inc.

    igPivotGrid_column_alignment.zip
Children