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.

Performance issues with ResizeToFit on a large dataset

Thread ID:

Created:

Updated:

Platform:

Replies:

60950 May 15,2007 08:46 PM Jun 19,2007 01:43 PM Windows Forms 4
loading
Tags: GridControl
Pratima
Asked On May 15, 2007 08:46 PM

Hi,
I am using GridDataBoundGrid from syncfusion suite 4.4.x.x version.
I have about 20000 rows in a dataset with 14 columns, that I display in the grid. I need to load all of the records as per my requirement.

Without the ResizeToFit call, the grid is populated and displayed in about 2-3 seconds including getting the data from a SQL database table.

When I make a call to ResizeToFit ( anytime after the data has been assigned to Grid's datasource ) it is taking about 1 min 30 seconds for the same size of data with everything exact same.

Here is the call I make:
gridDataBoundGrid1.Model.Cols.Size.ResizeToFit(GridRangeInfo.Table(), GridResizeToFitOptions.IncludeHeaders | GridResizeToFitOptions.NoShrinkSize);



I tried different size data and time varies depending on the size of the data.

Is this a bug in Syncfusion's call or am I doing something wrong?

Do you have any pearls of wisdom for me to speed up the performance ( alternate faster way to set the column widths based on max data )

Thanks,
Pratima




haneefm [Syncfusion]
Replied On May 16, 2007 11:44 AM

Hi Pratima,

The reason is that the ResizeToFit method will visit every cell in the range, and call MeasureString method to calculate the size of the cell. This will take time for large number of rows. But right now, You can speed up the process to limit the number of cells that you check. One simple way is to only resize the visible rows.

Another way would be to use something other than visiting each cell and calling MeasureString method. For example, if a column is a numeric value you could ’approximate’ the widest the cell could be by multiplying the max digits times the average character width for the font. This would just be a quick calculation without having to visit every cell. Or, if you know the maximum number of characters in a field of your database, you could set its width based on the max number of characters and the average character width. So, instead of calling ResizeToFit (and having it visit every cell), you would just call some calculation that would approximate the needed width.

This would be the only way to speed things up significantly now.

Best regards,
Haneef

Sumeet Koshal
Replied On June 19, 2007 12:43 AM

Hi Haneef,

Can you please provide me some sample for this(only resize the visible rows)?

Regards
Sumeet

>Hi Pratima,

The reason is that the ResizeToFit method will visit every cell in the range, and call MeasureString method to calculate the size of the cell. This will take time for large number of rows. But right now, You can speed up the process to limit the number of cells that you check. One simple way is to only resize the visible rows.

Another way would be to use something other than visiting each cell and calling MeasureString method. For example, if a column is a numeric value you could ’approximate’ the widest the cell could be by multiplying the max digits times the average character width for the font. This would just be a quick calculation without having to visit every cell. Or, if you know the maximum number of characters in a field of your database, you could set its width based on the max number of characters and the average character width. So, instead of calling ResizeToFit (and having it visit every cell), you would just call some calculation that would approximate the needed width.

This would be the only way to speed things up significantly now.

Best regards,
Haneef

Sumeet Koshal
Replied On June 19, 2007 05:52 AM

Haneef.

I am able to do this. so, no need to send me any sample.

Thanks
Sumeet

>Hi Haneef,

Can you please provide me some sample for this(only resize the visible rows)?

Regards
Sumeet

>Hi Pratima,

The reason is that the ResizeToFit method will visit every cell in the range, and call MeasureString method to calculate the size of the cell. This will take time for large number of rows. But right now, You can speed up the process to limit the number of cells that you check. One simple way is to only resize the visible rows.

Another way would be to use something other than visiting each cell and calling MeasureString method. For example, if a column is a numeric value you could ’approximate’ the widest the cell could be by multiplying the max digits times the average character width for the font. This would just be a quick calculation without having to visit every cell. Or, if you know the maximum number of characters in a field of your database, you could set its width based on the max number of characters and the average character width. So, instead of calling ResizeToFit (and having it visit every cell), you would just call some calculation that would approximate the needed width.

This would be the only way to speed things up significantly now.

Best regards,
Haneef

haneefm [Syncfusion]
Replied On June 19, 2007 01:43 PM

Hi Sumeet,

You could try doing it on demand in TopRowChanged. There you could size just the visible rows, (ViewLayout.VisibleCellsRange). This way you could size things a little at the time on demand when new rows are exposed.

[c#]
private void gridDataBoundGrid1_TopRowChanged(object sender, GridRowColIndexChangedEventArgs e)
{
GridDataBoundGrid grid = sender as GridDataBoundGrid;
grid.Model.RowHeights.ResizeToFit(grid.ViewLayout.VisibleCellsRange);
}

GDBGResizeToFit.zip

Best regards,
Haneef

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.

;