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

Manually setting width on columns produces inconsistent results

I am trying to set specific column width when the ggc load (using the code snippet below) and make specific column non-resizable. However, the ggc produces unexpected result. The column width are no where near what are set and are even out of proportion. Am i using the wrong calls?
this.gridGroupingControl.TableModel.ColWidths["Rate"] = 70; this.gridGroupingControl.TableModel.ColWidths["Total"] = 100;

3 Replies

AD Administrator Syncfusion Team September 28, 2006 08:59 AM UTC

Hi James,

For Resizable columns :

To change the individual column width manually,You could try this code snippet:

this.gridGroupingControl1.TableDescriptor.Columns["parentID"].Width = 175;

//For paticular table.
this.gridGroupingControl1.GetTableDescriptor("Deals").Columns["PaymentAmount"].Width=50;

For Non Resizable columns :

You can handle the QueryColWidth event and set the width of the fixed column. Below is a code snippet.

private void TableModel_QueryColWidth(object sender, GridRowColSizeEventArgs e)
{
GridTableModel model = sender as GridTableModel;
GridTableDescriptor td = model.Table.TableDescriptor;
int index = model.ColIndexToField(e.Index);

if( index != -1 && td.VisibleColumns.Count > index )
{
string ColName = td.VisibleColumns[index].Name;

if( ColName == "ParentName")
{
e.Size = 20;
e.Handled = true;
}
}
}

Thanks,
Haneef


JA jamesb September 28, 2006 05:14 PM UTC

Neither of the code below is working. When the grid load, the columns are all squished up!

this.gridGroupingControl.TableModel.ColWidths["col"] = 70;

this.gridGroupingControl.TableDescriptor.Columns["col"].Width = 175;


AD Administrator Syncfusion Team September 29, 2006 05:12 AM UTC

Hi James,

Sorry for the inconvenience caused.

If you can upload a sample showing the problem or tell us how to see the problem in one of the browser samples we ship, we can try to resolve the problem.

Thanks for your patience.

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon