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

Programmatic grid incorrect size

1 Answer 110 Views
Grid
This is a migrated thread and some comments may be shown as answers.
wonderbison
Top achievements
Rank 1
wonderbison asked on 20 Jun 2011, 11:57 AM
Hi
Building a hierarchical programmatic grid. The grid is held within a place holder

<form id="form1" runat="server" method="post">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="ContSelect">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="GridID" />
<telerik:AjaxUpdatedControl ControlID="ContSelect" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="GridID">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="GridID" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<
div class="contributionTable" >
    <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</div>

The grid is added to this placeholder. Here is also some of the code, I believe the code that covers relevant sections of building the grid. The full grid build code is not detailed here though.

The problem is that the grid takes up about 1/3 of the size of the IE browser. What I would like is for it to fill the browser with scrolling bars at the bottom and right. If the browser is expanded or contracted, the grid will resize (client side). Is this possible?

GridID1.ID = "GridID1";
GridID1.DataSource = contributionColumns;
GridID1.MasterTableView.DataKeyNames = new string[] { "TeamId" };
GridID1.Width = Unit.Percentage(98);
GridID1.PageSize = 5;
GridID1.AllowPaging = true;
GridID1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
GridID1.AutoGenerateColumns = false;
GridID1.ShowStatusBar = true;
GridID1.GroupingEnabled = true;
GridID1.ShowGroupPanel = false;
GridID1.ClientSettings.AllowDragToGroup = false;
GridID1.ClientSettings.AllowColumnsReorder = true;
GridID1.MasterTableView.PageSize = 20;
GridID1.MasterTableView.Width = Unit.Percentage(100);
GridID1.ClientSettings.Scrolling.FrozenColumnsCount = 2;
GridID1.ClientSettings.Scrolling.AllowScroll = true;
GridID1.ClientSettings.Resizing.EnableRealTimeResize = true;
salesTeam.DataSource = contributionColumns;
salesTeam.DataKeyNames = new string[] { "SMSId" }; 
salesTeam.Width = Unit.Percentage(100);
relationFields = new GridRelationFields();
salesTeam.ParentTableRelation.Add(relationFields);
GridID1.MasterTableView.GroupByExpressions.Add(new GridGroupByExpression("TeamFunction group by TeamFunction"));
GridGroupByExpression expression = new GridGroupByExpression();
GridGroupByField groupbyField = new GridGroupByField();
GridID1.MasterTableView.GroupByExpressions.Add(new GridGroupByExpression("SalesTeam group by SalesTeam"));
expression = new GridGroupByExpression();
groupbyField = new GridGroupByField();
boundColumn = new GridBoundColumn();
GridID1.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "SalesPerson";
boundColumn.HeaderText = "Sales person";
boundColumn.Visible = true;
foreach (DataColumn col in contributionColumns.Tables[0].Columns)
{
    if (col.Ordinal > 5)
    {
        boundColumn = new GridBoundColumn();
        GridID1.MasterTableView.Columns.Add(boundColumn);
        boundColumn.DataField = col.ColumnName;
        boundColumn.HeaderText = col.ColumnName;
        boundColumn.Visible = true;
    }
}
GridID1.DataBind();
this.PlaceHolder1.Controls.Add(GridID1);


1 Answer, 1 is accepted

Sort by
0
Galin
Telerik team
answered on 23 Jun 2011, 01:35 PM
Hello Robin,

You can control the space that RadGrid covers with the attributes "Height" and "Width". For both of them you have two possibilities: to set value in pixels or in percentage. The difference between  them is:
  • Pixels - in different scenario the Grid will have same size
  • Percentage - if you set the height in percents you have to keep in mind, that the grid is nested inside container. So the Control will calculate its dimensions in regards to this container pixel height.  Also it is possible this container to have height dimension in percentage and in this case you have to care about its wrapper (parent element) too. Finally you can set height=100% to <body> and <html> elements.
Please refer to this help project in our Code Library.

I hope this helps you.

Best wishes,
Galin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
wonderbison
Top achievements
Rank 1
Answers by
Galin
Telerik team
Share this question
or