简体   繁体   中英

How to control the width of radgrid

I have a RadGrid but it is spanning the width across the page, how can I control it and set a width and mae contents in the cells wrap if they need to?. I cant find anything that is helping me. I tried MasterTableView-TableLayout="fix" but then anything in the cells gets cut off. Any help would be much appreciated:

 <RadGrid:CustomRadGrid ID="DetailsGrid" runat="server" AutoGenerateColumns="False"
 ShowFooter="True" OnNeedDataSource="DetailsGrid_NeedDataSource" OnItemDataBound="DetailsGrid_ItemDataBound"
OnItemCreated="DetailsGrid_ItemCreated" 
OnItemCommand="DetailsGrid_ItemCommand"
GridLines="None" AllowFilteringByColumn="True" 
AllowPaging="True" 
AllowSorting="True"
AllowMultiRowSelection="true">

THIS IS A CUSTOM GRID

Use the Width attribute in the main RadGrid tag. Content in cells will automatically wrap. You may have to set the width on individual columns as well to get the appropriate look. The auto column width doesn't always wrap where you want it to.

For RadGrid width you just need to set width of the grid.

<telerik:RadAjaxPanel ID="RadAjaxPanel" runat="server">
    <telerik:RadGrid ID="ViewLogsGrid" FilterType="Combined"
            runat="server"
            AllowFilteringByColumn="true"                
            PageSize="50"
            ShowStatusBar="true"
            AllowPaging="True"
            AllowSorting="True"

            Width="1250px"

            AllowFiltering="True"
            AutoGenerateColumns="false"
            GridLines="None"
            CellSpacing="0">

    </telerik:RadGrid>
</telerik:RadAjaxPanel>

Columns inside the grid will adjust as needed but if you need to fix a column width do the following (Telerik doesn't recommend it);

<telerik:RadGrid ID="ViewLogsGrid" ... ... >

   <MasterTableView TableLayout="Fixed">
      <Columns>
        <telerik:GridBoundColumn DataField="Comments" HeaderText="Comments" SortExpression="Comments"    UniqueName="Comments">

           <HeaderStyle Width="150px" />

        </telerik:GridBoundColumn>
      </Columns>
   </MasterTableView>

</telerik:RadGrid>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM