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

[Solved] Extra space after the Grid when dynamically created the columns

1 Answer 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Qaja Mohiddin
Top achievements
Rank 1
Qaja Mohiddin asked on 06 Nov 2009, 08:42 AM
Hi,

I am dynamically creating columns(GridBoundColumn and GridNumericColumn). There are nearly 15-16 columns. So have added scroll bars to the Grid to avoid Page scroll bar. I got the Scroll bar for the grid but at the same time I am getting extra space after the Grid which results horizontal scroll bar to the page. Because of this entire layout has been changed.

My ASPX Code:

<telerik:RadGrid ID="RadGrid1" runat="server" Width="650px" BorderColor="#698AC0" 
                                                        BorderWidth="2px" BorderStyle="Solid" Skin="Vista" GridLines="Both" HeaderStyle-Font-Names="Verdana" 
                                                        HeaderStyle-Font-Size="9px" HeaderStyle-HorizontalAlign="Center" ItemStyle-Font-Size="9px" 
                                                        AutoGenerateColumns="false" AlternatingItemStyle-Font-Names="Verdana" AllowFilteringByColumn="True" 
                                                        CommandItemStyle-Width="50px" 
                                                        OnPreRender="RadGrid1_PreRender" OnNeedDataSource="RadGrid1_NeedDataSource" 
                                                        AllowSorting= "true" AlternatingItemStyle-Font-Size="9px" ShowFooter="true"
                                                        <ItemStyle Font-Names="Verdana" Font-Size="9px"></ItemStyle> 
                                                        <FilterItemStyle Font-Names="Verdana" Font-Size="9px" /> 
                                                        <MasterTableView  TableLayout="Auto" Width="650px"/> 
                                                        <ClientSettings> 
                                                            <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true"/> 
                                                        </ClientSettings>  
                                                    </telerik:RadGrid> 




My Code Behind :

protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
        {    
            DataSet RebateData = GetMSRebateDS(); 
            if (RadGrid1.Columns.Count == 0) 
            { 
                if (RebateData.Tables.Count > 0) 
                { 
                    foreach (DataColumn Column in RebateData.Tables[0].Columns) 
                    { 
                        ColList.Add(Column.ColumnName); 
                    } 
                } 
                PrepareGridColumns(ColList); 
            } 
             
            RadGrid1.DataSource = RebateData; 
        } 
 
 
 
 
private void PrepareGridColumns(List<string> ColList) 
        { 
            foreach (string Column in ColList) 
            { 
                if (Column == "PartnerName"
                { 
                    GridBoundColumn BoundCol = new GridBoundColumn(); 
                    RadGrid1.MasterTableView.Columns.Add(BoundCol); 
                    BoundCol.UniqueName = Column; 
                    BoundCol.HeaderText = Column; 
                    BoundCol.DataField = Column; 
                    BoundCol.HeaderStyle.Width = Unit.Pixel(70); 
                    BoundCol.FilterControlWidth = Unit.Pixel(40); 
                    BoundCol.SortExpression = Column;   
                    BoundCol.AllowFiltering = true
                } 
                else 
                { 
                    GridNumericColumn BoundNumCol = new GridNumericColumn(); 
                    RadGrid1.MasterTableView.Columns.Add(BoundNumCol); 
                    BoundNumCol.UniqueName = Column; 
                    BoundNumCol.HeaderText = Column; 
                    BoundNumCol.DataField = Column; 
                    BoundNumCol.HeaderStyle.Width = Unit.Pixel(70); 
                    BoundNumCol.FilterControlWidth = Unit.Pixel(40); 
                    BoundNumCol.SortExpression = Column;   
                    BoundNumCol.AllowFiltering = true
                } 
            } 
 
        } 


Help me to resolve this issue.

Thanks,
Malli


1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 06 Nov 2009, 02:46 PM
Hello Qaja,

From the code snippets it is difficult to say what exactly might caused getting extra space after the Grid. However, I suggest you review the following help article on the programmatic creation and see if it helps:
http://www.telerik.com/help/aspnet-ajax/grdprogrammaticcreation.html

Regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Qaja Mohiddin
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or