OLAP grid headers out of the screen

Posted by: abellisomi on 20 August 2020, 2:14 am EST

    • Post Options:
    • Link

    Posted 20 August 2020, 2:14 am EST - Updated 3 October 2022, 11:51 pm EST

    Hello,

    In my scenario I have an OLAP grid with many columns. This causes the headers to be off screen, so our users do not really know what are they looking at (see example). Is there a way to make the Column headers “scroll” so they are always visible, or at least to give a Tooltip to suggest what the group is about?

    Thank you

  • Posted 21 August 2020, 7:12 am EST

    Hi,

    Are you using the control inside some container other than standard Grid, like DockControl? C1OlapPage by default does show scrollbar, if any of the rows/columns do not fit in view.

    To show cell content as tooltip, you can access the grid component inside C1OlapPage and define a custom CellFactory, as follows:

    Access grid component from C1OlapPage:

    var grid = _c1OlapPage.OlapGrid as C1.WPF.FlexGrid.C1FlexGrid; if(grid != null)      grid.CellFactory = new TooltipCellFactory();
    Defining CellFactory for the grid: ```

    class TooltipCellFactory : C1.WPF.FlexGrid.CellFactory

    {

    public override FrameworkElement CreateCell(C1.WPF.FlexGrid.C1FlexGrid grid, C1.WPF.FlexGrid.CellType cellType, C1.WPF.FlexGrid.CellRange range)

    {

    var cell = base.CreateCell(grid, cellType, range);

    if (cellType == C1.WPF.FlexGrid.CellType.Cell || cellType == C1.WPF.FlexGrid.CellType.ColumnHeader)

    {

    cell.MouseEnter += (s, e) =>

    {

    var tip = string.Format(“{0}”, grid[range.Row, range.Column]);

    cell.ToolTip = tip;

    };

    }

    return cell;

    }

    }

  • Posted 21 August 2020, 7:19 am EST

    Ruchir,

    yes I confirm that I see horizontal scrollbars as well (the grid is contained in a DockContainer), the problem is that when the user access the page no information is immediately shown. The tooltip could be a solution, if nothing else can help

  • Posted 23 August 2020, 6:14 pm EST

    Hello,

    As I see from the image you shared, the top level column headers are merged for multiple columns. Depending on the text alignment of the header cells, it is expected that the text will not be visible if the control is not in full view or scrolled centrally.

    So, you can either set tooltips to show the header content or align the header text. You can try the following code: ```

    var grid = _c1OlapPage.OlapGrid as C1.WPF.FlexGrid.C1FlexGrid;

    if (grid != null)

    foreach (C1.WPF.FlexGrid.Column col in grid.Columns)

    col.HeaderHorizontalAlignment = HorizontalAlignment.Left;

  • Posted 23 August 2020, 10:14 pm EST

    Ruchir,

    Thanks for replying.

    I think I will go with the tooltip approach.

    The last question: how can I get the header text? Your example only shows random values for the column headers

    var tip = string.Format("{0}", grid[range.Row, range.Column]);
    
  • Posted 24 August 2020, 5:35 pm EST

    Hi,

    I am not sure what you meant by ‘Your example only shows random values for the column headers’?

    If you override the CreateCell method in CellFactory only for the ColumnHeader type, the tooltip will show column header content only.```

    public override FrameworkElement CreateCell(C1.WPF.FlexGrid.C1FlexGrid grid, C1.WPF.FlexGrid.CellType cellType, C1.WPF.FlexGrid.CellRange range)

    {

    var cell = base.CreateCell(grid, cellType, range);

    if (cellType == C1.WPF.FlexGrid.CellType.ColumnHeader)

    {

    cell.MouseEnter += (s, e) =>

    {

    var tip = string.Format(“{0}”, grid[range.Row, range.Column]);

    cell.ToolTip = tip;

    };

    }

    return cell;

    }

    If you are facing any trouble getting column header text in tooltip, please share a stripped down application.
    
    Regards,
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels