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 to set Column Width in a GridDataControl equal to the width taken by Stacked Header Column's content?

Thread ID:

Created:

Updated:

Platform:

Replies:

117641 Nov 21,2014 10:08 AM UTC Mar 9,2015 11:18 AM UTC WPF 5
loading
Tags: GridDataControl
Sanjhi
Asked On November 21, 2014 10:08 AM UTC

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

Jayapradha S [Syncfusion]
Replied On 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

Jayapradha S [Syncfusion]
Replied On 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

Gaurav Verma
Replied On 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

Sanjhi
Replied On 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.



Jayapradha S [Syncfusion]
Replied On 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 


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.

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

;