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

Grid Column No Wrap + Ellipsis

3 Answers 418 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Erwin
Top achievements
Rank 1
Erwin asked on 01 Mar 2010, 08:15 AM

Hello Everyone,

I Have a problem regarding a particular Grid Column.
I have a grid with many column. One Column is called "Description". In this column there is a posibility that the string is too long that it would wrap.

I already look this tutorial: "No wrap for grid cell content"  and my column did not wrap.
I also added

<style type="text/css">

 

.MasterTable_WebBlue td

{

overflow:hidden;

}

.GridHeader_WebBlue

{

overflow: hidden;

}

 

</style>

My problem now is that i need to display an Ellipsis "..."  on that column only.
I need to display ... before the string ends.

 

 

 


or 

Is there a way to dispaly "..." after a certain number of character?






 

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 01 Mar 2010, 10:39 AM
Hi Erwin,

The following code will help you to add ellipsis to cell text if its length overcomes a certain number of character.

C#:
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item;            
            if (item["City"].Text.Length > 4) 
            { 
                item["City"].ToolTip = item["City"].Text.ToString(); // Set the Tooltip 
                item["City"].Text = (item["City"].Text).Substring(0, 5) + "..."
            } 
        } 
    } 

Hope this helps,
Shinu.
0
Erwin
Top achievements
Rank 1
answered on 16 Mar 2010, 11:17 AM
Thank you...
This code works fine.
0
Andrea
Top achievements
Rank 2
Iron
answered on 27 Sep 2010, 04:43 PM
it works.. except when you export!
Tags
General Discussions
Asked by
Erwin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Erwin
Top achievements
Rank 1
Andrea
Top achievements
Rank 2
Iron
Share this question
or