Grid Column No Wrap + Ellipsis

4 posts, 1 answers
  1. Erwin
    Erwin avatar
    74 posts
    Member since:
    Apr 2009

    Posted 01 Mar 2010 Link to this post

    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?






     

  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 01 Mar 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Erwin
    Erwin avatar
    74 posts
    Member since:
    Apr 2009

    Posted 16 Mar 2010 Link to this post

    Thank you...
    This code works fine.
  5. Andrea
    Andrea avatar
    64 posts
    Member since:
    Jan 2005

    Posted 27 Sep 2010 Link to this post

    it works.. except when you export!
Back to Top