20
OLAP Grid Column width not
posted

Hi,

I have encountered below problems in the OLAP Grid. Would you please help me to overcome those problems.

-        Column widths always defaulting to column header width, which usually hides the values in the column that we want to see and that the Row grand total moving to the far right and off the screen (often leaving huge amounts of blank space). When we resize the columns manually and expand another node, all the resizing work done is gone.

- Any mechanism to save the state of the column widths in order to use it once user back in.

- Please let me know how to handle column resizing event

-        How to turn off Column “Grand Total” when we add hierarchy to the columns area. This value doesn't work because there are different metrics amongst the categories and it does not make sense to have a column grand total.

Thank you.

  • 23838
    Offline posted

    Hello Buddhika,

    The igPivotGrid columns widths can be defied by 2 options: defaultRowHeaderWidth and defaultColumnWidth. As a result all of the data columns end up with one and the same width, the one defined in the defaultColumnWidth option (There is no out of the box functionality that accommodates for the dynamic nature of the columns generated when a row/column is expanded). However the Resizing feature of the igGrid that the igPivotGrid uses internally has the necessary columnResizing event that you can handle and implement your own custom logic. Here is a code snippet demonstrating how you can handle the columnResizing event:

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

    //your custom logic here

    });

    In order to demonstrate how you can persist the column resized state between expand/collapse I used a custom variable to hold the state of the columns when resized and to restore it when the igPivotGrid is rendered. I'm attaching my sample for your reference. In the sample I handle 2 events: columnResized and pivotGridRendered. Here is the code for both handlers:

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

    colsCache = ui.owner.grid.options.columns;

    });

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

    for(var i = 0; i < colsCache.length; i++) {

    try {

    $("#pivotGrid_table").data("igGridResizing").resize(colsCache[i].key, colsCache[i].width);

    } catch (e) {}

    }

    });

    In the columnResized there is a code to persist the current state of the columns and in the pivotGridRendered the igGridResizing.resize API is used to restore the columns widths.

    As for the "Grand Total" question. The answer depends on whether you're using OlapFlatDataSource or OlapXmlaDataSource. In the former you can remove the "Grand Total" from the data source configuration. For the later you should modify your BI solution and remove it from there.

    Best regards,
    Martin Pavlov
    Infragistics, Inc.

    igPivotGrid_resizing_persist_columns.zip