We have been trying to get the RadGrid to allow horizontal scrolling (if the width of the columns exceeds our grid width), but make the height auto adjust to the number of rows that are contained within it.
We are generating the Grid dynamically like so...
If we set the AllowScroll property to false, then the vertical scrolling acts appropriately, but we then don't get the horizontal scrolling that is required.
We are generating the Grid dynamically like so...
var telerikGrid =
new
RadGrid
{
ID =
"RadGrid1"
,
DataSource = request.dataTable,
AllowSorting =
true
,
AllowPaging =
true
,
Width = Unit.Pixel(980),
AutoGenerateColumns =
true
,
GridLines = GridLines.Both,
Skin = ddlStyle.SelectedValue ??
"Black"
};
//telerikGrid.MasterTableView.TableLayout = GridTableLayout.Fixed;
//Scrolling
telerikGrid.ClientSettings.Scrolling.AllowScroll =
true
;
//telerikGrid.ClientSettings.Scrolling.SaveScrollPosition = true;
telerikGrid.ClientSettings.Scrolling.UseStaticHeaders =
true
;
telerikGrid.ClientSettings.Selecting.AllowRowSelect =
true
;
telerikGrid.ClientSettings.Scrolling.FrozenColumnsCount = 1;
//telerikGrid.ClientSettings.Scrolling.ScrollHeight = Unit.Percentage(100);
telerikGrid.MasterTableView.VirtualItemCount = request.dataTable.Rows.Count;
//telerikGrid.ClientSettings.Scrolling.ScrollHeight = Unit.Percentage()
//Resizing
telerikGrid.ClientSettings.Resizing.AllowColumnResize =
true
;
//Reordering
telerikGrid.ClientSettings.AllowColumnsReorder =
true
;
//Export
telerikGrid.MasterTableView.CommandItemSettings.ShowExportToExcelButton =
true
;
telerikGrid.MasterTableView.Visible =
true
;
telerikGrid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
telerikGrid.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
If we set the AllowScroll property to false, then the vertical scrolling acts appropriately, but we then don't get the horizontal scrolling that is required.