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. Image for the cookie policy date
close icon

How to set Column Width in a GridDataControl equal to the width taken by Stacked Header Column's content?

Hi,

I have a requirement where I need to set the width of my columns in grid control depending on the width taken up by the Stacked Header Column (or Stacked Header Column's Header Text!).
Apparently, I have templated Stacked Headers (with Header Text and a button or some really long Header Text!) which appears cropped on the grid or text wraps (which looks ugly!), especially in the case when Column Span is set to 1.... which is happening because the Column Size depends on Column Header and not Stacked Header.
PFA..

As far as I have seen GridDataStackedHeaderColumn, I don't think there is any way to control it's column width.

Can you tell me is there a way to achieve this?

Thanks,
Sanjhi.

Attachment: StackedHeaderCoulmnResizeIssue_290b0582.zip

5 Replies

JS Jayapradha S Syncfusion Team November 27, 2014 12:18 PM UTC

Hi Sanjhi,

 

Thanks for contacting support.

 

We have analyzed your requirement and found that you can achieve this by setting the minimum width based on your header text length in GridLoaded event.

 

We have prepared a sample for this and please find the same from the below link:

 

Sample Link:

 

Please let us know if you need any further assistance.

 

Regards,

Jayapradha


Attachment: StackedHeaders_6fb9e59a.zip


JS Jayapradha S Syncfusion Team November 27, 2014 12:34 PM UTC

Hi Sanjhi,

 

Please ignore the previous update.

 

We have analyzed your requirement and found that you can achieve this by setting the minimum width based on your header text length in GridLoaded event.

 

We have prepared a sample for this and please find the attached sample.

 

Please let us know if you need any further assistance.

 

Regards,

Jayapradha


Attachment: StackedHeaders_bf1a5ac8.zip


GV Gaurav Verma December 1, 2014 11:51 AM UTC

Hi Jayapradha,

Sanjhi is not available so I will take this discussion further on her behalf. We can not set the minimum width as the header text is dynamic. The solution you have provided is good when we have static sh text but when we have dynamic header text then this solution will fail. Can you please suggest any solution for dynamic sh?

Thanks,
Gaurav Verma


SA Sanjhi March 9, 2015 09:19 AM UTC

Hi Jayapradha,

I was wondering if you can provide me any update on the above issue. As Gaurav already mentioned we cannot use your solution as the header text in our case is also dynamic in nature.

Can you please tell me is it possible to do what we want to achieve?

Thanks
Sanjhi.




JS Jayapradha S Syncfusion Team March 9, 2015 11:18 AM UTC

Hi Sanjhi and Gaurav,

 

We are sorry about the delay caused.

 

We have analyzed your requirement and we don’t have the provision to support to change the stacked header width at runtime. You can avoid the stackedheader text trimming by setting the width for column header under the stacked header as shown in the below code snippet. Otherwise, you can set the width for stacked header while grid loading as we suggested in our previous attached sample.

 

Code Snippet:

<syncfusion:GridDataStackedHeaderRow Name="Row1" >

                <syncfusion:GridDataStackedHeaderRow.Columns>

                        <syncfusion:GridDataStackedHeaderColumn HeaderText="ResourcesNeededStackedHeader" Name="Header1" ColumnSpan="1" />

                        <syncfusion:GridDataStackedHeaderColumn HeaderText="Header 2" Name="Header2"  ColumnSpan="1"/>

                </syncfusion:GridDataStackedHeaderRow.Columns>

                </syncfusion:GridDataStackedHeaderRow>

</syncfusion:GridDataControl.StackedHeaderRows>

            <syncfusion:GridDataControl.VisibleColumns>

                <syncfusion:GridDataVisibleColumn MappingName="OrderID" IsIdentity="True" HeaderText="Order ID" MinimumWidth="300" />

 

 

Kindly let us know if you have any other queries.

 

Regards,

Jayapradha 


Loader.
Live Chat Icon For mobile
Up arrow icon