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

Show only first 50 chars in a specific column

1 Answer 39 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Felice
Top achievements
Rank 1
Felice asked on 09 Jan 2015, 05:58 AM
In a RadTreeList I need to show only the first 50 chars in a specific column unless a session variable is valid.

<telerik:TreeListBoundColumn UniqueName="TextM" DataField="TextM" HeaderText="Message" HeaderStyle-Width="400">
 <HeaderStyle Width="400px" ></HeaderStyle>
</telerik:TreeListBoundColumn>

Is there a way to achieve such feature?

Thanks for supporting,

Felice

1 Answer, 1 is accepted

Sort by
0
Felice
Top achievements
Rank 1
answered on 10 Jan 2015, 06:05 AM
I found the solution. I post it just in case someone else may need it.
My target was to show only part of the text in a specific column of the RadTreeList if the user is not logged in.
I derived it from the RadGrid and I achieved the result in this way:

protected void RadTreeList1_ItemDataBound(object sender, TreeListItemDataBoundEventArgs e)
   {
       if (string.IsNullOrEmpty(Session["UserLogged"] as string))
       {
           if (e.Item is TreeListDataItem)
           {
              TreeListDataItem item = (TreeListDataItem)e.Item;
              if (item["TextM"].Text.Length > 49)
              {
                item["TextM"].ToolTip = "Please login to read the full message";
                item["TextM"].Text = (item["TextM"].Text).Substring(0, 50) + "...";
               }               
           }
       }
   }
Regards
Tags
TreeList
Asked by
Felice
Top achievements
Rank 1
Answers by
Felice
Top achievements
Rank 1
Share this question
or