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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I correctly size dynamically added grid columns.

Thread ID:





123775 Apr 20,2016 12:01 PM UTC Apr 21,2016 01:24 PM UTC UWP 1
Tags: SfDataGrid
Deanna Delapasse
Asked On April 20, 2016 12:01 PM UTC

I have an SfDataGrid whose columns are dynamically added.  When there is an auto-suggest control in the cell I would like it to remain as wide as the text in the dropdown box (so the dropdown text is readable).  See attached screenshot.  They seem to always size into equal sections regardless of the ColumnSizer setting.

Also, other columns are numeric, but have multi-word names.  I'd like the header text to wrap the individual words so the column size can be decreased to fit the number.

I have tried setting ColumnSizer on the datagrid declaration, but the columns seem to remain equally sized across the grid.  Another idea, I could use the * and 2* to specify the width, but I can't figure out how to set the star-widths on the GridTextColumns (width only allows numerics).

Any advice would be appreciated!

Attachment: uglygrid_6c8f81e8.zip

Jai Ganesh S [Syncfusion]
Replied On April 21, 2016 01:24 PM UTC

Hi Deanna,

Query 1:

You can achieve your requirement by customizing the GridColumnSizer and overrides the CalculateCellsWidth method.

KB Link: https://www.syncfusion.com/kb/5972/how-to-customize-the-width-of-the-gridcomboboxcolumn-based-on-its-headertext-and-items

Query 2:

You can achieve your requirement for calculating the star width for a column by customizing the ColumnSizer. We already have a kb regarding this and please find the kb link as below,

Kb Link:




Jai Ganesh S


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon