This is a migrated thread and some comments may be shown as answers.

RadGrid Height / ScrollHeight issue

1 Answer 156 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Guilhem
Top achievements
Rank 1
Guilhem asked on 28 Mar 2017, 06:53 AM

Hello,

I have a Radgrid with many columns, and without paging.

My users needs to (and can) scroll horizontally to read all the fields. But only by using the horizontal scrolling at the bottom of the grid, which is not convenient when the Grid has 100 rows or more. (If you want to read the first row, you need to scroll down the page, scroll right the grid, scroll up the page again).

I tried to use the ScrollHeight attribute but nothing happens. I also tried to add a height to my RadGrid, the grid itself respect the height but the rows don't (and overflow on the grids below).

I create my grid from the code behind so here is the code where it happens.

Can you help me ?

Thank you !

RadGrid grid = new RadGrid();
grid.ID = gridID;
grid.DataSourceID = dataSourceID;
grid.AllowMultiRowSelection = true;
grid.AllowPaging = false;
grid.ColumnCreated += Grid_ColumnCreated;
grid.BatchEditCommand += Grid_BatchEditCommand;
grid.AllowAutomaticUpdates = true;
grid.AllowAutomaticDeletes = true;
grid.AllowAutomaticInserts = false;
grid.AutoGenerateColumns = true;
//grid.Height = Unit.Pixel(300);
 
/* Client Settings */
grid.ClientSettings.Selecting.AllowRowSelect = true;
grid.ClientSettings.Selecting.UseClientSelectColumnOnly = true;
grid.ClientSettings.Scrolling.AllowScroll = true;
grid.ClientSettings.Scrolling.UseStaticHeaders = false;
grid.ClientSettings.Scrolling.ScrollHeight = Unit.Pixel(200);
grid.ClientSettings.ClientEvents.OnGridCreated = "SetupButtons";
grid.ClientSettings.ClientEvents.OnKeyPress = "GridKeyPress";
grid.ClientSettings.ClientEvents.OnCommand = "OnGridCommand";
 
/* HeaderStyle */
grid.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
grid.HeaderStyle.BorderWidth = 1;
 
/* MasterTableView */
grid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
grid.MasterTableView.TableLayout = GridTableLayout.Fixed;
grid.MasterTableView.DataKeyNames = new string[] { dataKey };
grid.MasterTableView.EditMode = GridEditMode.Batch;
grid.MasterTableView.BatchEditingSettings.EditType = GridBatchEditingType.Cell;
 
/* CommandItemSettings */
grid.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false;
grid.MasterTableView.CommandItemSettings.ShowRefreshButton = true;
grid.MasterTableView.CommandItemSettings.ShowCancelChangesButton = true;
grid.MasterTableView.CommandItemSettings.ShowSaveChangesButton = true;
 
 
/* Actions Columns */
GridClientSelectColumn selectColumn = new GridClientSelectColumn();
selectColumn.UniqueName = "ClientSelectColumn";
selectColumn.HeaderStyle.Width = Unit.Pixel(50);
grid.Columns.Add(selectColumn);
 
GridClientDeleteColumn deleteColumn = new GridClientDeleteColumn();
deleteColumn.UniqueName = "ClientDeleteColumn";
deleteColumn.HeaderStyle.Width = Unit.Pixel(50);
grid.Columns.Add(deleteColumn);
 
/* ADDING EVERYTHING ON THE PAGE */
Grids.Controls.Add(info); //info is a RadLabel
Grids.Controls.Add(grid);
RadAjaxManager1.AjaxSettings.AddAjaxSetting(grid, info, RadAjaxLoadingPanel);
RadAjaxManager1.AjaxSettings.AddAjaxSetting(grid, grid, RadAjaxLoadingPanel);
 
 
protected void Grid_ColumnCreated(object sender, Telerik.Web.UI.GridColumnCreatedEventArgs e)
{
    if (e.Column is GridBoundColumn)
    {
        GridBoundColumn column = (GridBoundColumn)e.Column;
        if (isHidden)
        {
            column.Display = false;
            column.ReadOnly = true;
        }
        else
        {
            if (isReadOnly)
            {
                column.ReadOnly = true;
            }
 
            //Change column header
            column.HeaderText = text;
            column.HeaderStyle.Width = Unit.Pixel(size);
            column.HeaderTooltip = tooltip;
        }
    }
}

1 Answer, 1 is accepted

Sort by
0
Guilhem
Top achievements
Rank 1
answered on 29 Mar 2017, 01:57 AM

My bad ! The issue was coming from a custom css (that we created and used in another of our teleric project).

.rgDataDiv { height : auto !important ; }

is obviously a bad idea when we want to control the size of the grid.

Tags
Grid
Asked by
Guilhem
Top achievements
Rank 1
Answers by
Guilhem
Top achievements
Rank 1
Share this question
or