Flexgrid autosize rows - only visible columns

Posted by: mary431982 on 6 May 2019, 6:00 am EST

  • Posted 6 May 2019, 6:00 am EST

    Hi,

    how can I achieve that rows are autosized only based on the content of the Visible columns?

  • Posted 7 May 2019, 7:35 am EST

    In order to auto size the rows, you could use autoSizeRows() method of Flexgrid. This method is used to resize the ranges to fit the cell’s content. You can call this method in the loadedRows event to flexgrid. Please refer to the code snippet below:

    flexgrid.loadedRows.addHandler(function(s, e) {
           flexgrid.autoSizeRows();
    });
    
    

    API Reference:

    autoSizeRows method:

    https://www.grapecity.com/wijmo/api/classes/wijmo_grid.flexgrid.html#autosizerows

    https://www.grapecity.com/wijmo/api/classes/wijmo_grid.flexgrid.html#autosizerow

  • Posted 8 May 2019, 11:10 am EST

    Thnx, I understand all of that,

    my problem is that you are taking into account ALL columns, not just VISIBLE ones,

    for example - first I have one visible column which has very large content,

    and the height is adjusted to that content,

    then I hide that column and I show another column with small content,

    and then when I call autosize rows - the height is adjusted to the large content of the HIDDEN column and NOT to the small content of the shown column??!!

  • Posted 9 May 2019, 5:35 am EST

    Hi Mary,

    The current behavior is by design. On calling the autoSizeRow(s) method on scrolling when the visible area is changed, it may affect the FlexGrid performance.

    However, we have forwarded this request to the concerned team for further investigation with an internal tracking id 378429. We will let you know as we get an update on this.

    Regards,

    Manish Gupta

  • Posted 10 May 2019, 6:04 am EST

    Thanx!!!

    Regards,

    Mary

  • Posted 18 July 2019, 3:18 pm EST

    Hi,

    Do you by any chance have any news concerning this issue?

    I am facing the same problem and thought of changing the hiding functionnality in the meantime. I am using a reference column collection and removing or adding the columns depending on the hidden property.

    It is definitly not the best solution so if you have any advice it would be appreciated.

    Regards,

    Adrien

  • Posted 19 July 2019, 5:18 am EST

    Hi Adrien,

    The autoSizeColumns function only takes those columns into account which are not visible on the grid because their visible property is set to false. If a column is not visible on the screen or if its height/width is set to 0, it still counts as visible.

    If you wish to auto-size only those columns which are visible on the screen, you may need to auto-size each column in visible range manually by calling autoSizeColumn() on each column. Please refer to the code snippet below:

    var rng = flexgrid.viewRange;
    for(let i = rng.leftCol; i <= rng.rightCol; i++) {
        flexgrid.autoSizeColumn(i);
    }
    

    Regards,

    Ashwin

  • Posted 19 July 2019, 8:17 am EST

    Hi Ashwin,

    First of all thank you for your fast reply.

    Unfortunatly what you suggested does not seem to work in my case.

    I have a fixed column widths and only want to manage the height of my rows.

    Thank you anyway,

    Regards,

    Adrien

  • Posted 19 July 2019, 8:31 am EST

    Hi Adrien,

    You can also auto-size rows using the same procedure. You just need to use the autoSizeRow method instead of autoSizeColumn. Refer to the updated code below:

    var rng = flexgrid.viewRange;
    for(let i = rng.leftCol; i <= rng.rightCol; i++) {
        flexgrid.autoSizeRow(i);
    }
    

    Please let us know if this solves your issue or otherwise.

    Regards,

    Ashwin

  • Posted 19 July 2019, 11:09 am EST

    Thank you but that is exactly the subject of this thread … AutoSizeRow cannot take into account hidden columns and I end up with a bigger row than needed. Plus as your colleague Manish said it is unsafe performance wise

  • Posted 24 July 2019, 5:59 am EST

    Hi Adrien,

    We are sorry for the delayed response.

    This issue in this thread was that the autoSizeRows method of FlexGrid takes all of the columns into account even if the column is not visible. But, the autoSizeRows method does not take invisible columns into account.

    The reason for this is that there is no element for the column due to which the height and width of the content of the column cannot be determined so we cannot determine what should be the dimensions of the cell element.

    Could you please try calling the autoSizeRows() method before changing the visibility of a column and let us know if this works for you?

Need extra support?

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

Learn More

Forum Channels