Clear cells if row has expanded data

2 posts, 0 answers
  1. Patrick
    Patrick avatar
    6 posts
    Member since:
    Feb 2009

    Posted 30 Nov 2010 Link to this post

    I have a tree view with financial information.  For a row that is not expanded, the cells show the totals of the hidden rows below.  When expanding a row (showing the details), I want to clear the cells of the parent row so I just show the detail.

    Below is the relevant code, it is firing for the secondary rows, but not for the expanded row.  

    Thanks,

    Pat

        private void radTreeListView1_RowLoaded(object sender, RowLoadedEventArgs e)
        {
          var row = e.Row as TreeListViewRow;
          if (row != null)
          {
            var binding = new Binding("IsRowExpanded") { Source = row.Item };
            binding.Mode = BindingMode.TwoWay;
            row.SetBinding(TreeListViewRow.IsExpandedProperty, binding);
          }
        }
      }
      public class HeaderRowSelector : DataTemplateSelector
      {
        public DataTemplate BlankCell    { getset; }

        public DataTemplate NormalCell    { getset; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
          FFSLStoreReportDataItem itm = item as FFSLStoreReportDataItem;

          if(itm.IsRowExpanded)
            return BlankCell;
          else
             return NormalCell;

        }
      }
    }

    namespace FFSLClient.FFSLServer
    {
      public partial class FFSLStoreReportDataItem
      {
        private bool _IsRowExpanded;
        public bool IsRowExpanded
        {
          get
          {
            System.Diagnostics.Debug.WriteLine("Getting IsRowExpanded, Value:" + _IsRowExpanded.ToString());
            return _IsRowExpanded;
          }
          set
          {
            System.Diagnostics.Debug.WriteLine("SETTING IsRowExpanded, Value:" + value.ToString());
            _IsRowExpanded = value;
          }
        }
      }
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 06 Dec 2010 Link to this post

    Hello Patrick,

    Yes, RowLoaded event is not appropriate in this case.

    Please try with the RowIsExpandedChanging or RowIsExpandedChanged events and let us know if it helps.


    Greetings,
    Veselin Vasilev
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. DevCraft banner
Back to Top