Hey All, I am loading a grid dynamically via DataBind. As indicated I've turned off AutoGenerateColumns and set BoundDataFields and ColumnBehaviors for all the columns. All appears to be working except that I'm not getting a scrollbar when I resize any column larger than the width of the grid.
I've tried forcing the sum of the columns to initially be larger than the width of the grid panel.
I've set the width of the grid in pixels as indicated in this link https://es.infragistics.com/community/blogs/b/taz_abdeali/posts/under-the-hood-of-new-aikido-webdatagrid-contd Can anyone tell me how to force the scrollbars to show up?
Are you also setting the width on individual columns? You will need to set them to get a horizontal scrollbar to show up. If you are using 2009.2, then there is a property called DefaultColumnWidth added to the WebDataGrid, setting that property will give a default width to all the columns and you should see a scrollbar if the the columns can't fit in the grid area.
hth,
Taz.
Yeah, I am setting the individual columns. We're in the process of upgrading to 2009.2 we have to fix some minor bugs as a result of the upgrade, but in 2009.1 I used the following code to set the column widths
private void AutoSetColumnWidths() { if (_dataSet == null || _dataSet.Tables[0] == null) return;
foreach (DataColumn column in _dataSet.Tables[0].Columns) { BoundDataField field = new BoundDataField(); field.Key = column.ColumnName; field.Header.Text = column.ColumnName; field.Width = 100; flatGrid.Columns.Add(field);
var setting = new ColumnResizeSetting(); setting.ColumnKey = column.ColumnName; setting.EnableResize = true; setting.MinimumWidth = 50; setting.MaximumWidth = 150; flatGrid.Behaviors.ColumnResizing.ColumnSettings.Add(setting); } }
The horizontal scrollbar is still not appearing. Any ideas?
Ok, we added a property in 9.2 called DefaultColumnWidth. This property is avaiable off of the grid itself. You can set the column width here and all the column will default to that width. If the total column widths is greater than the grid width then a horizontal scrollbar will appear.
Hope this helps.
-Taz.
Can you use DefaultColumnWidth to make the column auto fit its contents? I tried using "auto" but it wouldn't accept it.
Leaving the property empty serves the same purpose as "auto". If you have a width set off the control itself then the columns will stretch to the size of its data and create a scrollbar if needed. Otherwise the grid will be as large as the data is.