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.

Column Width and ExpandAllGroups

Thread ID:

Created:

Updated:

Platform:

Replies:

78444 Dec 12,2008 01:21 PM Jan 5,2009 11:55 PM ASP.NET Web Forms (Classic) 3
loading
Tags: GridGroupingControl
Saurabh Srivastava
Asked On December 12, 2008 01:21 PM

Hi,

I am trying to fix up the width of columns. My columns are being generated at runtime. Hence, on page load if I do grid.tabledescriptor.columns[0].width=100
it gives me a null reference exception. What is another way of doing it?

Also, I have set the ExpandAllGroups on the page load but it doesnt seem to work. I am using the latest version for Syncfusion (6.402.0.15).

Please help.


Saurabh Srivastava
Replied On December 13, 2008 06:36 AM


Hi,

I am able to refernce columns now. I was not binding at runtime and that was the reason why it was not accessible. The ExpandAllGroups() now works fine. But I am still not able to alter the width of the columns. I am applying a custom CSS on the grid. Is that the reason for it?




Rajarajeswari S [Syncfusion]
Replied On December 15, 2008 01:21 AM

Hi Saurabh,

I am afraid that I am not able to reproduce the issue, that you have mentioned here. Applying Custom CSS doesn’t affect of setting column width. Please refer the below sample where I have followed the below things:

1. Created Grid, and applied custom CSS.
2. Creating a new column dynamically.
3. Setting width for the dynamically created column.
4. The width is applied to the column properly.

Please refer the below code snippet which illustrates this:

protected void Button1_Click(object sender, EventArgs e)
{
this.GridGroupingControl1.TableDescriptor.Columns.Add("NewColumn");
GridColumnDescriptor gcd = this.GridGroupingControl1.TableDescriptor.GetColumnDescriptor("NewColumn");
gcd.Width = 300;
}

Please refer the sample from the below link, which illustrates the above:

http://www.syncfusion.com/support/user/uploads/Sample_f8581c1.zip

Please let me know if you have any other concerns.

Regards,
Raji



Saurabh Srivastava
Replied On January 5, 2009 11:55 PM

Hi,

I tried all possible combinations to set the column width, but none seems to work.

I am creating the columns dynamically by a stored procedure.

Following are the methods are I tried:

//METHOD 1
this.GridGroupingControl1.TableDescriptor.Columns[1].MaxLength = 10;

//METHOD 2
for (int i = 0; i < this.GridGroupingControl1.TableDescriptor.Columns.Count; i++) this.GridGroupingControl1.TableDescriptor.Columns[i].Width = 20;

//METHOD 3
this.GridGroupingControl1.TableDescriptor.Columns[1].MaxLength = 10; this.GridGroupingControl1.TableOptions.ColumnsMaxLengthStrategy = GridColumnsMaxLengthStrategy.MaxLengthSummary;

//METHOD 4
this.GridGroupingControl1.TableOptions.DefaultColumnWidth = 10;

//METHOD 5
GridColumnDescriptor gcd = this.GridGroupingControl1.TableDescriptor.GetColumnDescriptor("myColumn");
gcd.Width = 20;

This is my design time defn of Gridgrouping control:
ShowGroupDropArea="False" BorderCollapse="Separate" OnQueryCellStyleInfo="cControl_QueryCellStyleInfo" OnQueryCoveredRange="cControl_QueryCoveredRange" EnablePostbacks="false" TableDescriptor-AllowEdit="false" TableOptions-AllowDragColumns="false" Width="400"
TableOptions-AllowSortColumns="false" ReadOnly="true" TableDescriptor-AllowColumnResize="false">


Please advise.

Thanks




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.

;