Custom Group Headers via CellFactory

Posted by: taran.twomey on 4 August 2021, 5:59 pm EST

  • Posted 4 August 2021, 5:59 pm EST

    Hi,

    I am attempting to use a custom cell factory with the Wijmo Flexgrid, and have noticed some strange issues regarding row groups. When using a custom cell factory to render cells, I have noticed that normal cells only come through updateCell() on creation/destruction (or via change detection like editing values etc.), and the same cell is not re rendered while scrolling until it is out of the view. This means that cells are only calculated once on creation until they are either updated or destroyed.

    This is not the same for row group headers, which seem to come through the updateCell() function every single time the user scrolls, even if the row group header is not being created or destroyed (via leaving the view). This is especially an issue when putting components into the group row, as it causes them to be constantly recreated, which can cause flickering and is computationally expensive.

    This does not seem to be an issue if we don’t use a custom cell factory, as the custom component is only loaded when the row header enters the view, and is not re loaded on every scroll.

    Here is a stackblitz showcasing an example of this problem in action: https://stackblitz.com/edit/angular-txm51s?devtoolsheight=33&file=src/app/app.component.ts

    While the console is open, if you scroll on the first grid you will see that the component is constantly printing, which only happens once on component creation. If you then scroll on the second grid you will notice that the component does not constantly print, and instead only prints when a row group comes into view.

    In the stack blitz you will find in my custom cell factory that I have already attempted to mitigate the recreation of components via some code that has been commented out:

    
      if ((this.groupRows[row.index]?.dataItem !== row.dataItem || cell.innerHTML.length === 0)) {
      //if we haven't rendered this row before (its html length is 0), or this is a new set of data, re render the group header.
      this.buildTemplateCell(this.groupHeader, cell, context);
      this.groupRows[row.index] = row;
    }
    
    

    This code stops the component being constantly re created, but causes issues when expanding and collapsing the group rows, as the header seems to use data taken from another cell.

    Is there a better way to be handling group rows when using a custom cell factory? How can I achieve having custom components in my group row header using a cell factory without them being re rendered every time the user scrolls?

    Note that while I can get this to work without a cell factory, the cell factory significantly boosts performance when rendering cells as opposed to using itemFormatters, so I would prefer to use a custom cell factory if I can.

  • Posted 6 August 2021, 12:20 am EST

    Hi Taran,

    This seems like an issue in the control. I have forwarded a report to the developers for further investigation with internal tracking id WJM-20596. I will update you once I will hear back from them.

    Regards,

    Ashwin

  • Posted 15 May 2022, 3:14 pm EST

    Any updates to this? We’d love to know if there is any more information related to this issue.

  • Posted 17 May 2022, 2:24 pm EST

    Hello,

    We apologize but the issue is still at the Dev team, I have asked the team to prioritize this issue and provide an update at the earliest.

    Sorry for the inconvenience.

    Regards

Need extra support?

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

Learn More

Forum Channels