C1Flexgrid RowHeaders AutoSizeColumn

Posted by: scottadelong on 27 October 2018, 1:18 am EST

    • Post Options:
    • Link

    Posted 27 October 2018, 1:18 am EST

    I have both bound and unbound C1Flexgrids with * “multiple”

    RowHeaders.

    For both cases I am trying to resize (autofit) the RowHeaders’ columns’ width to fit its contents.

    I would like to know which event I should use to call my method to accomplish this, such as C1Flexgrid.Loaded, and what method to call, such as C1Flexgrid.RowHeaders.AutoSizeFixedColumns.

    Also, is your recommended solution going to only affect visible cells? If so, what is your recommended approach so that all cells, including ones that haven’t been rendered, have the appropriate width, such as the C1Flexgrid.RowHeaders.AutoSizeFixedColumns parameter “bool allCells”?

    Will this have an increasingly negative performance impact due to it negating virtualization and if so, what recommendations have you made to your clients to work around this limitation?

    Again, I am looking for solutions in both bound and unbound data scenarios.

    Thank you very much for your time.

  • Posted 28 October 2018, 8:30 pm EST

    Hello,

    ​To autosize/autofit the width of the row header column according to the content in it, you need to invoke AutoSizeFixedColumns​ method in C1FlexGrid’s Loaded event as follows:```

    private void unboundFlex_Loaded(object sender, RoutedEventArgs e)

    {

    _flex.AutoSizeFixedColumns(0, 1, 10);

    }

    Now, to consider invisible cells as well while resizing the row header column, there is allCells parameter that needs to be set true. However, I am observing few issues with it so I have forwarded it to concerned team [Id: 350598] and will get back to you as soon as there is an update on it.
    Regarding the performance, invoking [i]AutoSizeFixedColumns [/i]method with allCell =true will impact the performance of the application adversely since this can consume lot of time as the grid needs to measure and create cell considering the entire grid content.
    For more information, please refer 'Remarks' section in following page: http://help.grapecity.com/componentone/NetHelp/c1flexgridwpfsilv/webframe.html#C1.Silverlight.FlexGrid.5~C1.Silverlight.FlexGrid.C1FlexGrid~AutoSizeFixedColumns(Int32,Int32,Double,Boolean,Boolean).html
    Regards,
    Ruchir
  • Posted 31 October 2018, 2:24 am EST

    AutoSizeFixedColumns(0, RowHeaders.Columns.Count - 1, 0);

    Above worked for me. I was working with a Flexgrid that had two RowHeader columns and one regular column so using Columns.Count (which only considers regular columns) was essentially leaving me with:

    AutoSizeFixedColumns(0, 0, 0);

  • Posted 31 October 2018, 2:56 am EST

    As far as trying to handle cells that have not yet been visually rendered, rather than overloading the parameter allCells with true and potentially crushing performance by negating virtualization with very large sets of data, I have set a call to AutoSizeFixedColumns in ScrollPositionChanged event as well.

    I have not noticed an impact to performance and it is behaving as I hoped.

  • Posted 31 October 2018, 6:06 pm EST

    Hello,

    The issue that setting allCells parameter in AutoSizeFixedColumns method does not work, has been confirmed by development team as Bug.

    Meanwhile the issue is being fixed, apart from invoking the AutoSizeFixedColumns method ScrollPositionChanged event,even you may use the following workaround:```

    private void BoundFlex_Loaded(object sender, RoutedEventArgs e)

    {

    boundFlex.AllowMerging = AllowMerging.Cells;

    boundFlex.AutoSizeFixedColumns(0, RowHeaders.Columns.Count - 1, true, false);

    boundFlex.AllowMerging = AllowMerging.None;

    }

    private void unboundFlex_Loaded(object sender, RoutedEventArgs e)

    {

    unboundFlex.AllowMerging = AllowMerging.Cells;

    unboundFlex.AutoSizeFixedColumns(0, RowHeaders.Columns.Count - 1, 10, true, false);

    unboundFlex.AllowMerging = AllowMerging.None;

    }

    
    Regards,
    Ruchir
    [zip filename="RowHeader_C1FlexGrid.zip"]https://gccontent.blob.core.windows.net/forum-uploads/file-6213b72c-efd2-4bf3-b00f-bc647582ed99.zip[/zip]
  • Posted 6 November 2018, 3:18 am EST

    I very much appreciate your time.

  • Posted 12 December 2018, 10:04 pm EST

    Hi

    I am happy to inform you that this issue has been fixed in the latest release. You can access the same using: http://prerelease.componentone.com/hotfixes/wpf/C1WPFBasicLibrary.4_4.0.20183.614.zip

    Thanks

    Ruchir

Need extra support?

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

Learn More

Forum Channels