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

how to specify column column size for particular columns?...

2 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 08 Nov 2010, 08:54 AM
Hey everyone,

I have a radgrid,its need data source event is--
protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            RadGrid1.DataSource = GetDataTable("SELECT UID, Email_TemplateName as 'Name', Mail_Text as 'Mail text',Mail_Subject as 'Mail Subject' FROM Entry");
        }
i have no columns defined otherwise in the grid definition.Also i have hided the page size dropdown and i want the size of grid to be always of 10 items and no matter how much no. of items are present in the grid.

Thanks
Amit

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 08 Nov 2010, 09:29 AM
Hello Amit,

You can set the size of Autogenerated column from code behind.
C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
   {
       RadGrid1.MasterTableView.AutoGeneratedColumns[0].ItemStyle.Width = Unit.Pixel(300); //setting size of first AutoGeneratedColumn
   }

And set the PageSize property on the grid or table view to specify the number of records that should appear in each chunk.
ASPX:
<telerik:RadGrid ID="RadGrid1"  runat="server" AllowPaging="true" PageSize="10">
         

Thanks,
Princy.
0
Accepted
Dimo
Telerik team
answered on 08 Nov 2010, 09:30 AM
Hi Amit,

You can set column widths by using the ColumnCreated event and the columns' HeaderSyle-Width property.

http://www.telerik.com/help/aspnet-ajax/grdusingcolumns.html

You can control the RadGrid height with its Height and ScrollHeight (only when scrolling is used) properties.

http://www.telerik.com/help/aspnet-ajax/height-vs-scrollheight.html

If the control is currently displaying e.g. 5 rows, you can't have 5 "filled" rows and 5 "empty" rows.

Regards,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Amit
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Dimo
Telerik team
Share this question
or