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

Set Grid Column ABBR

3 Answers 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jako
Top achievements
Rank 1
Jako asked on 24 May 2012, 01:00 PM
Hi there

I have a very long description field in my radgrid, what I would like to do is display the first 50 chars and then have a mouse over event that will show the full description.

Normally I do this with the <abbr> tag, but not sure how to apply this to a radgrid, or even if there is a built in function to handle something like this?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 May 2012, 01:24 PM
Hello Jako,

Try setting the tooltip for the cell as shown below.
C#:
void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem)
 {
  GridDataItem item = (GridDataItem)e.Item;
  if (item["UniqueName "].Text.Length > 50)
  {
    TableCell cell = item["UniqueName"];
     cell.ToolTip=cell.Text ;
  }
 }
}

Thanks,
Princy.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 24 May 2012, 01:37 PM
Hello,

<telerik:GridTemplateColumn DataField="ID" HeaderText="ID" UniqueName="ID">
                       <ItemTemplate>
                           <asp:Label ID="txtID" runat="server" Text='<%# Eval("ID") %>'></asp:Label>
                       </ItemTemplate>
                      
                   </telerik:GridTemplateColumn>
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            Label txtID = item.FindControl("txtID") as Label;
            if (txtID.Text.Length > 2)
            {
                txtID.ToolTip = txtID.Text.Substring(2);
                txtID.Text = txtID.Text.Substring(0, 2);
            }
        }
    }


Thanks,
Jayesh Goyani
0
Jako
Top achievements
Rank 1
answered on 25 May 2012, 09:32 AM
Hi guys

Thanks, works perfect.

Must say, these controls you guys are developing are top class!
Tags
Grid
Asked by
Jako
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jayesh Goyani
Top achievements
Rank 2
Jako
Top achievements
Rank 1
Share this question
or