Cell/Row Double click event not working when RowDetailsVisibilityChanged or LoadingRowDetails events are registered

6 posts, 0 answers
  1. Maulik Patel
    Maulik Patel avatar
    36 posts
    Member since:
    Mar 2010

    Posted 19 May 2011 Link to this post

    Hi,


    I am using "RowDetailsVisibilityChanged" and "LoadingRowDetails" events to show the small record form for the selected row. This works well. I am facing couple of problems as below.


    1. When user selects a row, RowDetails area show the record form (perfectly find). But when user moves the selected row off the screen scrolling down (using the vertical scrollbar) and make the row detail area hidden, The selected row's detail area gets collapsed automatically. How can I stop auto hide in this scenario?


    2. The second problem is, Row double click does not work (to open a record form of the selected row) if above events are registered. On double click, Row details area loads. Once it is loaded (and row is selected), user can do a double click.

    Is there any way to bypass LoadingRowDetails event when double click is done?


    I have used following statement to register cell double click: 
    (this.RadGridView1 as RadGridView).RemoveHandler((Telerik.Windows.RoutedEvent)GridViewCell.CellDoubleClickEvent, (EventHandler<Telerik.Windows.RadRoutedEventArgs>)this.OnGridViewCellDoubleClick);



    Quick help is really appreciated.

    Regards,
    Maulik
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 20 May 2011 Link to this post

    Hello Maulik Patel,

     Unfortunately I was not able to reproduce the behavior that you are experiencing when user moves the selected row off the screen scrolling down(issue #1). Could you please specify how exactly are you expanding your details view?

    Regarding your issue #2 - I am not sure that I understand your problem properly. You talk that the row double click does fires. After that : "Once it is loaded (and row is selected), user can do a double click". I am not sure what does this mean. 
    I have tested the double click like this and it fires appropriately when "RowDetailsVisibilityChanged" and "LoadingRowDetails" events are registered:

    this.clubsGrid.AddHandler(GridViewCellBase.CellDoubleClickEvent, new EventHandler<RadRoutedEventArgs>(OnCellDoubleClick), true);
    private void OnCellDoubleClick(object sender, RadRoutedEventArgs args)
           {
               GridViewCellBase cell = args.OriginalSource as GridViewCellBase;
           }


    Could you please share with us how you register to the double click event?

    It would be best if you could isolate your issues in a very simple, sample project, so that we could clearly see your requirements. That way we will be able to properly advice you. 

    Kind regards,
    Didie
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Maulik Patel
    Maulik Patel avatar
    36 posts
    Member since:
    Mar 2010

    Posted 31 May 2011 Link to this post

    Hi Didies,

    Thanks for providing the information. I am registering the double click event in the same way as you mentioned, below is the sample code for reproducing the problem# 2. If the control (which is loading in the RowDetailTemplate) is taking sometime to load it, Double click event is not loading.

    Please take a look.


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using Telerik.Windows.Controls;
    using Telerik.Windows.Controls.GridView;
    using System.Collections;
    using System.Windows.Data;
    using System.Windows.Markup;
    using Telerik.Windows.Data;
    using Telerik.Windows;
     
    namespace TelericGridViewTry
    {
       
        public partial class MainPage : UserControl
        {
            public List<object> rList = new List<object>();
            bool bTemp;
            public MainPage()
            {
                InitializeComponent();
                 
                if (this.ELV != null) this.ELV.ClearValue(RadGridView.ItemsSourceProperty);
     
                #region Add Dummy Data
                rList.Add(new Customer("first1", "last1", 10));
                rList.Add(new Customer("first2", "last2", 20));
                rList.Add(new Customer("first3", "last3", 10));
                rList.Add(new Customer("first4", "last4", 20));
                rList.Add(new Customer("first5", "last5", 10));
                rList.Add(new Customer("first6", "last6", 20));
                rList.Add(new Customer("first7", "last7", 10));
                rList.Add(new Customer("first8", "last8", 20));
                rList.Add(new Customer("first9", "last9", 10));
                rList.Add(new Customer("first10", "last10", 20));
                rList.Add(new Customer("first11", "last11", 10));
                rList.Add(new Customer("first12", "last12", 20));
                rList.Add(new Customer("first13", "last13", 10));
                rList.Add(new Customer("first14", "last14", 20));
                rList.Add(new Customer("first1", "last1", 10));
                rList.Add(new Customer("first2", "last2", 20));
                rList.Add(new Customer("first3", "last3", 10));
                rList.Add(new Customer("first4", "last4", 20));
                rList.Add(new Customer("first5", "last5", 10));
                rList.Add(new Customer("first6", "last6", 20));
                rList.Add(new Customer("first7", "last7", 10));
                rList.Add(new Customer("first8", "last8", 20));
                rList.Add(new Customer("first9", "last9", 10));
                rList.Add(new Customer("first10", "last10", 20));
                rList.Add(new Customer("first11", "last11", 10));
                rList.Add(new Customer("first12", "last12", 20));
                rList.Add(new Customer("first13", "last13", 10));
                rList.Add(new Customer("first14", "last14", 120));
                rList.Add(new Customer("first2", "last2", 20));
                rList.Add(new Customer("first3", "last3", 10));
                rList.Add(new Customer("first4", "last4", 20));
                rList.Add(new Customer("first5", "last5", 10));
                rList.Add(new Customer("first6", "last6", 20));
                rList.Add(new Customer("first7", "last7", 10));
                rList.Add(new Customer("first8", "last8", 20));
                rList.Add(new Customer("first9", "last9", 10));
                rList.Add(new Customer("first10", "last10", 20));
                rList.Add(new Customer("first11", "last11", 10));
                rList.Add(new Customer("first12", "last12", 20));
                rList.Add(new Customer("first13", "last13", 10));
                rList.Add(new Customer("first14", "last14", 120));
                #endregion
     
                ELV.ItemsSource = rList;
     
                //ELV.SetBinding(RadGridView.ItemsSourceProperty, new Binding("rList") { Source = this, Mode = BindingMode.TwoWay });
                ELV.Rebind();
                ELV.LoadingRowDetails += new EventHandler<GridViewRowDetailsEventArgs>(ELV_LoadingRowDetails);
                ELV.RowDetailsVisibilityChanged += new EventHandler<GridViewRowDetailsEventArgs>(ELV_RowDetailsVisibilityChanged);
                this.ELV.IsSynchronizedWithCurrentItem = false;
                this.ELV.SelectionMode = System.Windows.Controls.SelectionMode.Single;
               // this.ELV.RowDetailsVisibilityMode = GridViewRowDetailsVisibilityMode.Collapsed;
                //this.ELV.EnableRowVirtualization = false;
                (this.ELV as RadGridView).RemoveHandler((Telerik.Windows.RoutedEvent)GridViewCellBase.CellDoubleClickEvent, (EventHandler<Telerik.Windows.RadRoutedEventArgs>)this.OnGridViewCellDoubleClick);
                (this.ELV as RadGridView).AddHandler(GridViewCellBase.CellDoubleClickEvent, new EventHandler<Telerik.Windows.RadRoutedEventArgs>(this.OnGridViewCellDoubleClick), true);
           }
     
            void ELV_RowDetailsVisibilityChanged(object sender, GridViewRowDetailsEventArgs e)
            {
                if (e.DetailsElement != null)
                {
                    if (((StackPanel)e.DetailsElement).Children != null && ((StackPanel)e.DetailsElement).Children.Count > 0 &&
                        ((StackPanel)e.DetailsElement).Children[0] is InfoPage)
                    {
                        InfoPage ef = ((StackPanel)e.DetailsElement).Children[0] as InfoPage;
     
                    }
                }
            }
     
     
            void ELV_LoadingRowDetails(object sender, GridViewRowDetailsEventArgs e)
            {
     
                InfoPage i = new InfoPage();
     
                ((StackPanel)e.DetailsElement).Children.Clear();
                i.Visibility = Visibility.Collapsed;
               // MessageBox.Show("Visibility.Collapsed");
                ((StackPanel)e.DetailsElement).Children.Add(i);
                i.Visibility = Visibility.Visible;
                i.DataContext = e.Row.DataContext;
     
                var text1 = e.DetailsElement.FindName("textBox1") as TextBox;
                 
            }
     
            private void ELV_SelectionChanged(object sender, SelectionChangeEventArgs e)
            {
               
                InfoPage i = new InfoPage();
                this.ELV.RowDetailsTemplate = CreateRowDetailsTemplate();
                
            }
            private DataTemplate CreateRowDetailsTemplate()
            {
                DataTemplate dt = new DataTemplate();
                string xaml = "<DataTemplate x:Name='dt' xmlns='http://schemas.microsoft.com/client/2007' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:basics='clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls'  >"
                                + "<StackPanel Orientation='Vertical' HorizontalAlignment='Left'>";
                        xaml = xaml + "</StackPanel>"
                    + "</DataTemplate>";
                dt = XamlReader.Load(xaml) as DataTemplate;
                return dt;
            }
     
            private void OnGridViewCellDoubleClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
            {
                //if (!e.Handled)
                    MessageBox.Show("Double Click is called");
                //e.Handled = true;
            }
        }
     
        public class Customer
        {
            string m_FirstName;
     
            public string FirstName
            {
                get { return m_FirstName; }
                set { m_FirstName = value; }
            }
            string m_LastName;
     
            public string LastName
            {
                get { return m_LastName; }
                set { m_LastName = value; }
            }
            int m_Age;
     
            public int Age
            {
                get { return m_Age; }
                set { m_Age = value; }
            }
     
            public Customer(string FirstNanme, string LastName, int Age)
            {
               this.FirstName= FirstNanme;
               this.LastName = LastName;
               this.Age = Age;
            }
        }
    }


    ** Control to be loaded in the Detail Template Runtime...
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using System.Windows.Navigation;
     
    namespace TelericGridViewTry
    {
        public partial class InfoPage : Page
        {
            public InfoPage()
            {
                InitializeComponent();
                //It will take some time to load the form actually.
                for (int i = 0; i < 100000000; i++)
                {
                }
            }
     
            // Executes when the user navigates to this page.
            protected override void OnNavigatedTo(NavigationEventArgs e)
            {
            }
     
        }
    }




    Regards,
    Maulik
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 01 Jun 2011 Link to this post

    Hello Maulik Patel,

     I have reproduced the mentioned behavior. If the control (which is loading in the RowDetailTemplate) is taking sometime to load it, it blocks the UI. This way the UI does not receive the double click - it receives two single clicks as the time interval between the clicks is too large. 

    You will need to optimize or change the way that you are loading the DataTemplates. Instead of using double click event you may as well use the RowActivated event of the GridView.

    Kind regards,
    Didie
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Maulik Patel
    Maulik Patel avatar
    36 posts
    Member since:
    Mar 2010

    Posted 01 Jun 2011 Link to this post

    Hi Didies,


    Thanks for the response. I checked the "RowActivated" event but it behaves similarly (is not raised because UI is blocked). Is there any event that gets fired/raised after "LoadingRowDetails" event? Using that event (if any), I can call some method (that takes time to load the particular control) later after RowDetail is loaded.

    Thanks for your support.

    Regards,
    Maulik
  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 02 Jun 2011 Link to this post

    Hello Maulik Patel,

     If you are loading the RowDetails when you are expanding the Details row, then the RowDetailsVisibilityChanged (that you already use) will be raised after the "LoadingRowDetails" (when RowDetails is loaded) . There is not another appropriate event of the RadGridView that will fire after them.

    Have you tried to use RowTemplateSelector? Using it you may load the templates initially and just apply the appropriate template instead of loading the row details template every time. You may find an online example here. On our help page there is an general article about the template selectors.

    If the RowTemplateSelecor is not an option in your project, could you please share with us more information about what is your full scenario. This way we may suggest you another approach to achieve it.

    Greetings,
    Didie
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
DevCraft banner