Show only first 50 chars in a specific column

2 posts, 0 answers
  1. Felice
    Felice avatar
    198 posts
    Member since:
    Aug 2013

    Posted 08 Jan 2015 Link to this post

    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
  2. Felice
    Felice avatar
    198 posts
    Member since:
    Aug 2013

    Posted 10 Jan 2015 in reply to Felice Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top