We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Need to reset GridDataControl column sizing to Auto after programmatically resetting visible columns

Thread ID:

Created:

Updated:

Platform:

Replies:

121896 Feb 4,2016 10:58 AM Feb 9,2016 06:28 AM WPF 5
loading
Tags: GridDataControl
Steve McWilliams
Asked On February 4, 2016 10:58 AM

My gridDataControl is set with ColumnSizer=Auto in XAML and it initially displays  columns sized according to header / cell size as expected.
But when user picks new columns to display, I clear out the VisibleColumns and add new ones in .cs code.
But then it seems the 'Auto' format is lost, because all the columns display with a fixed size that is much larger than necessary.
How do I restore Auto column sizing in .cs code ?

Ambarish Srinivasan [Syncfusion]
Replied On February 7, 2016 11:04 PM

Hi Steve,

Currently we are working on your requirement and will provide the solution on February 8th, 2016.

Regards,
Ambarish.

Jayapradha S [Syncfusion]
Replied On February 8, 2016 07:40 AM

Hi Steve,

You can restore the Auto column sizer to grid by invoking RefreshAll() method as shown in the below code snippet,

Code Example:

private void AddColumns()       

        {

            this.syncgrid.VisibleColumns.Clear();

            this.syncgrid.VisibleColumns.Add(new GridDataVisibleColumn() { MappingName = "JobNumber", HeaderText = "Open Unit" });

            this.syncgrid.VisibleColumns.Add(new GridDataVisibleColumn() { MappingName = "ProductID" });

            this.syncgrid.VisibleColumns.Add(new GridDataVisibleColumn() { MappingName = "ProductName" });

            this.syncgrid.VisibleColumns.Add(new GridDataVisibleColumn() { MappingName = "Quantity" });

            this.syncgrid.ClearValue(GridDataControl.ColumnSizerProperty);

            this.syncgrid.ColumnSizer = GridControlLengthUnitType.Auto;

            this.syncgrid.Model.ColumnAutoSizer.RefreshAll();
        }


Please let me know if you have any further query.

Regards,
Jayapradha



Steve McWilliams
Replied On February 8, 2016 10:22 AM

I get error saying I cannot access internal method 'RefreshAll()' here

Steve McWilliams
Replied On February 8, 2016 03:30 PM

However, the problem seems to be fixed anyway  just by the first two lines, doing the ClearValue() and resetting sizer to auto.

Jayapradha S [Syncfusion]
Replied On February 9, 2016 06:28 AM

Hi Steve,

Yes, the reported auto column sizer problem will be fixed by clearing and resetting the value of column sizer as shown in our previous code example.

Regarding the query, I get error saying I cannot access internal method 'RefreshAll()' here:

In your version (10.3), RefreshAll method is not exposed for public use. As reset column sizer solves your problem, you can use the same.

Please let me know if you have any other concern.

Regards,
Jayapradha


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;