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

Columns not wrapping and overextending their boundaries

3 Answers 343 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 29 Mar 2012, 03:36 AM
Hi My RadGrids column width's are not being constrained.
It doesn't matter if i set the header-item-width or the whole radgrid's with or item-width or put div tags around it and constrain the size of the div, - the RadGrid will grow as much as needed to fit all of it's data it will grow to way off the screen, it will not wrap the column's data either.

I've attached a screenshot to illustrate the issue.

And here is the aspx code--- do you see any reason why the column is going off the page like crazy?

    <div style="width:1000px">
    <telerik:RadGrid ID="rgLCSLog" runat="server" AutoGenerateColumns="False" 
        CellSpacing="0" GridLines="None" AutoGenerateDeleteColumn="True" 
        onneeddatasource="rgLCSLog_NeedDataSource" AutoGenerateEditColumn="True" 
        oninsertcommand="rgLCSLog_InsertCommand" 
        ondeletecommand="rgLCSLog_DeleteCommand" 
        onupdatecommand="rgLCSLog_UpdateCommand" Width="1000px">
             
            <MasterTableView CommandItemDisplay="Top" EditMode="EditForms" DataKeyNames="id" >
                <CommandItemSettings AddNewRecordText="Add LCS Log" 
                    />
                
                <Columns>
                    <telerik:GridBoundColumn DataField="time_off" 
                        FilterControlAltText="Filter column column" HeaderText="Time Off" 
                        UniqueName="column">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="time_on" 
                        FilterControlAltText="Filter column1 column" HeaderText="Time On" 
                        UniqueName="column1" DataType="System.DateTime">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="equipment_area" 
                        FilterControlAltText="Filter column2 column" HeaderText="Equip/Area" 
                        UniqueName="column2">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="affected_customers" 
                        FilterControlAltText="Filter column3 column" HeaderText="Affected Customers" 
                        UniqueName="column3" HeaderStyle-Width="100px">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Account_Representative" 
                        FilterControlAltText="Filter column4 column" HeaderText="Acct Rep" 
                        UniqueName="column4">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="last_updated" 
                        FilterControlAltText="Filter column5 column" HeaderText="Last Updated" 
                        UniqueName="column5">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="last_updated_by" 
                        FilterControlAltText="Filter column6 column" HeaderText="Last Updated By" 
                        UniqueName="column6">
                    </telerik:GridBoundColumn>
                </Columns>
                <EditFormSettings UserControlName="~/ReportControls/AddEditGridControls/AddEditLCSLog.ascx" EditFormType="WebUserControl">
                    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                    </EditColumn>
                </EditFormSettings>
            </MasterTableView>                
    </telerik:RadGrid>
  
</div>

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Mar 2012, 06:32 AM
Hello Patrick,

Try setting TableLayout as Fixed and Wrap property as true as shown below.
aspx:
<MasterTableView TableLayout="Fixed" >
 <Columns>
  <telerik:GridBoundColumn   DataField="Title" UniqueName="Title" HeaderText="Title">
  <HeaderStyle Wrap="true" />
  </telerik:GridBoundColumn>
 </Columns>
</MasterTableView>

Thanks,
Shinu.
0
Patrick
Top achievements
Rank 1
answered on 29 Mar 2012, 03:41 PM
Hi,
 That partly resolved the issue, the Table no longer grows off the page, however words longer than the column width are not wrapping, they are getting cut off.
How can i get the words to wrap?
0
Shinu
Top achievements
Rank 2
answered on 30 Mar 2012, 10:17 AM
Hello Patrick,

If there are no spaces in the word, it will not be wrapped. So the options are to either introduce spaces to the string, or clip it. For clipping - set a fixed width for the column and allow clipping of cell contents from the Resizing settings of the control. Here is the sample code.
aspx:
<telerik:GridBoundColumn DataField="Title" UniqueName="Title" HeaderText="Title">
 <ItemStyle Width="120px" />
</telerik:GridBoundColumn>
<ClientSettings>
   <Resizing AllowColumnResize="true"  ClipCellContentOnResize="true" />
</ClientSettings>
Another alternative would be would be setting the tooltip for cell , which would show the complete text of the cell, when the user hovers over it and cut the cell text to particular length. Here is the sample code.
C#:
void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
 if (e.Item is GridDataItem)
 {
   GridDataItem item = (GridDataItem)e.Item;
   TableCell cell = (TableCell)item["Title"];
   cell.ToolTip = cell.Text;
 }
}

Thanks,
Shinu.
Tags
Grid
Asked by
Patrick
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Patrick
Top achievements
Rank 1
Share this question
or