Expand button disappears in RadTreeListView

9 posts, 0 answers
  1. Dalibor
    Dalibor avatar
    9 posts
    Member since:
    Oct 2011

    Posted 03 Oct 2012 Link to this post

    Hi Telerik,
    After running code bellow expand button disappears. Click e.g. on Carrot in my sample.
    The bug can be found at at least 2 latest releases including the newest SP release.
    I tried to simplify it to smallest possible code.
    This code causes to disappear expand arrow:
    public partial class MainPage : UserControl
      {
         public MainPage()
         {
            InitializeComponent();
            radTreeListView.ItemsSource = WarehouseService.GetWarehouseData();
            radTreeListView.RowLoaded += radTreeListView_RowLoaded;
         }
      
         void radTreeListView_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
         {
            TreeListViewRow treeRow = e.Row as TreeListViewRow;
            if (treeRow != null)
            {
               treeRow.IsExpandable = true; // this line causes to disappear expandable arrow
            }          
         }
      }
    ...
    public class WarehouseService
    {
       public static ObservableCollection<WarehouseItem> GetWarehouseData()
       {
          ObservableCollection<WarehouseItem> data = new ObservableCollection<WarehouseItem>();
          WarehouseItem drinks = new WarehouseItem("Drinks", 35);
          WarehouseItem water = new WarehouseItem("Water", 10);
          water.Items.Add(new WarehouseItem("Fresh", 10));
          water.Items.Add(new WarehouseItem("Salty", 10));
          drinks.Items.Add(water);
          WarehouseItem tea = new WarehouseItem("Tea", 20);
          tea.Items.Add(new WarehouseItem("Black", 10));
          tea.Items.Add(new WarehouseItem("Green", 10));
          drinks.Items.Add(tea);
          drinks.Items.Add(new WarehouseItem("Coffee", 5));
          data.Add(drinks);
          WarehouseItem vegetables = new WarehouseItem("Vegeatbles", 75);
          vegetables.Items.Add(new WarehouseItem("Tomato", 40));
          vegetables.Items.Add(new WarehouseItem("Carrot", 25));
          vegetables.Items.Add(new WarehouseItem("Onion", 10));
          data.Add(vegetables);
          WarehouseItem fruits = new WarehouseItem("Fruits", 55);
          fruits.Items.Add(new WarehouseItem("Cherry", 30));
          fruits.Items.Add(new WarehouseItem("Apple", 20));
          fruits.Items.Add(new WarehouseItem("Melon", 5));
          data.Add(fruits);
          return data;
       }
    }
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 04 Oct 2012 Link to this post

    Hi,

     Can you post more info about your treelist version? 

    All the best,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Dalibor
    Dalibor avatar
    9 posts
    Member since:
    Oct 2011

    Posted 04 Oct 2012 Link to this post

    Hi,
    The version is 2012.2.912.1050. I tried also a version before with the same result.
    Workaround is also welcome.
    Dalibor
  5. Vera
    Admin
    Vera avatar
    263 posts

    Posted 08 Oct 2012 Link to this post

    Hi Dalibor,


    May i ask you to share more details about your scenario? What would be the expected behavior?

    Looking forward to hearing from you.

     

    All the best,
    Vera
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Dalibor
    Dalibor avatar
    9 posts
    Member since:
    Oct 2011

    Posted 09 Oct 2012 Link to this post

    Hi Telerik,
    My expectation is that all expandable buttons are visible after click. See this video https://rapidshare.com/files/950332071/2012-10-09_1048.zip
    You can see that buttons appear again if I play with it a bit.
    Dalibor
  7. Shawn
    Shawn avatar
    2 posts
    Member since:
    Oct 2010

    Posted 17 Oct 2012 Link to this post

    I have the exact same problem.  I've traced the problem back to the Q2 2011 performance enhancements made in the RadGridView and RadTreeListView controls.  If I use the Q1 2011 SP1 libraries, then the code below works great - expanding a treelistviewitem shows it's children and all other parent items keep their expand buttons.  If I use the Q2 2011 SP1 libraries (or any other later version including the latest Q2 2012 SP2), then when I click on an expand icon then most other expand icons disappear.  Closing the expanded item shows the other expand icons again.

    In debugging through the code, the radTreeListViewRowLoaded method is only being called on some of the visible rows in the RadTreeListView, not all of them.  In the Q1 2011 SP1 libraries, the radTreeListViewRowLoaded is called on all visible rows.

    The rows that have radTreeListViewRowLoaded called show up correctly.  All rows are apparently reset to default every time any row is expanded and those who don't have radTreeListViewRowLoaded called have their expand button disappear.  If I scroll the TreeListView so these rows are hidden and then visible again, then the rows correctly show the expand button.

    I've attached screen shots of before clicking an expand button and after.

  8. Dalibor
    Dalibor avatar
    9 posts
    Member since:
    Oct 2011

    Posted 07 Dec 2012 Link to this post

    Any update?
  9. Dalibor
    Dalibor avatar
    9 posts
    Member since:
    Oct 2011

    Posted 29 May 2013 Link to this post

    Hi Telerik,
    would you please update us if you have already solved the problem?
    Dalibor
  10. Shawn
    Shawn avatar
    2 posts
    Member since:
    Oct 2010

    Posted 29 May 2013 Link to this post

    I put in a support ticket, and here is the response I got:
    ----------------------
    Hi Shawn,

     I've changed a bit your code to illustrate you how to fix this. Please use styles/styles selectors instead RowLoaded. Our optimization affected this since now rows are not removed but reused and RowLoaded will not be raised while styles will be reevaluated. 

    I've attached modified version of your project for reference. 

    Greetings,
    Vlad
    the Telerik team
    --------------------------

    Here is my original xaml code:
    <telerik:RadTreeListView x:Name="dgSummary" ItemsSource="{Binding SummaryInstalled}"
    RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" IsReadOnly="True"
    SelectionMode="Extended" BorderBrush="{x:Null}" CanUserFreezeColumns="False"
    GridLinesVisibility="None" ShowGroupPanel="False" RowLoaded="DgSummaryRowLoaded"
    RowIsExpandedChanging="DgSummaryRowIsExpandedChanging" Margin="0">

    This is what Vlad suggested in the xaml, and it works for me:
    <telerik:RadTreeListView x:Name="dgSummary" ItemsSource="{Binding SummaryInstalled}"
    RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" IsReadOnly="True"
    SelectionMode="Extended" BorderBrush="{x:Null}" CanUserFreezeColumns="False"
    GridLinesVisibility="None" ShowGroupPanel="False"
    RowIsExpandedChanging="DgSummaryRowIsExpandedChanging" Margin="0">
                 
    <telerik:RadTreeListView.RowStyle>
        <Style TargetType="telerik:TreeListViewRow">
             <Setter Property="IsExpandable" Value="{Binding IsExpandable}" />
        </Style>
    </telerik:RadTreeListView.RowStyle>

    This was my original code behind file:
    private void DgSummaryRowLoaded(object sender, RowLoadedEventArgs e)
    {
        var row = e.Row as TreeListViewRow;
        if (row != null)
        {
            row.IsExpandable = ((ProductSummary) row.DataContext).LdmsProductType == LdmsProduct.ProductGroup;
        }
    }

    Vlad suggested removing the DgSummaryRowLoaded method and instead extending my ProductSummary object using the following code:
    public partial class ProductSummary
    {
        public bool IsExpandable
        {
            get { return LdmsProductType == LdmsProduct.ProductGroup; }
        }
    }

    Hope this helps you if you are experiencing the same problems!
    Shawn
Back to Top
DevCraft banner