GridViewCommandRow and Grouping

5 posts, 0 answers
  1. Michele
    Michele avatar
    426 posts
    Member since:
    Jun 2009

    Posted 19 Nov 2012 Link to this post

    Hello,
    I've defined a GridViewCommandRow and it's defined as

    public class GridViewCommandRow
       {
           public static readonly DependencyProperty IsEnabledProperty =
               DependencyProperty.RegisterAttached("IsEnabled",
                                                   typeof(bool),
                                                   typeof(GridViewCommandRow),
                                                   new PropertyMetadata(false, OnIsEnabledChanged));
     
           public GridViewCommandRow(RadGridView grid)
           {
               RadGridView = grid;
               CommandRow = new ContentControl();
               CommandRow.SetValue(Grid.RowProperty, 0);
     
               if (ViewCommandTemplate == null)
               {
                   var commandRowTemplate = Generic.GetInstance()["CommandRowTemplate"] as ControlTemplate;
     
                   if (commandRowTemplate != null)
                       ViewCommandTemplate = commandRowTemplate;
               }
           }
     
           public ControlTemplate ViewCommandTemplate { get; set; }
     
           private ContentControl CommandRow { get; set; }
     
           public RadGridView RadGridView { get; private set; }
     
           public static void SetIsEnabled(DependencyObject dependencyObject, string enabled)
           {
               bool convertedValue = Convert.ToBoolean(enabled);
               dependencyObject.SetValue(IsEnabledProperty, convertedValue);
           }
     
           public static object GetIsEnabled(DependencyObject dependencyObject)
           {
               return dependencyObject.GetValue(IsEnabledProperty);
           }
     
           private static void OnIsEnabledChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
           {
               var radGridView = sender as RadGridView;
               if (radGridView != null)
               {
                   if ((bool)e.NewValue)
                   {
                       // Create new GridViewCommandRow and attach RadGridView events.
                       var commandRow = new GridViewCommandRow(radGridView);
     
                       commandRow.Attach();
                   }
               }
           }
     
           private void Attach()
           {
               RadGridView.DataLoaded += RadGridView_DataLoaded;
           }
     
           private void RadGridView_DataLoaded(object sender, EventArgs e)
           {
               if (RadGridView.Items.Count > 0)
               {
                   RadGridView.SelectedItem = RadGridView.Items[0];
               }
     
               Grid hierarchyGrid =
                   RadGridView.ChildrenOfType<Grid>().FirstOrDefault(c => c.Name == "HierrarchyBackground");
     
               if (hierarchyGrid != null && CommandRow.Parent == null)
               {
                   hierarchyGrid.Children.Add(CommandRow);
     
                   CommandRow.Template = ViewCommandTemplate;
               }
           }
       }

    I've noticed that setting it I lose the grouping feature...is there a way to put it above the group panel?
    Thanks
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 19 Nov 2012 Link to this post

    Hi Paolo ,

    Please find the logic which inserts this row into the visual structure of RadGridview.
    Most probably it happens in the void RadGridView_DataLoaded(object sender, EventArgs e)
    method.

    Remove this logic and place the row above RadGridView like an ordinary external control.This should solve the problem.

    Kind regards,
    Pavel Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Michele
    Michele avatar
    426 posts
    Member since:
    Jun 2009

    Posted 19 Nov 2012 Link to this post

    Hello Pavel,
    your approach is ok but I looses the meaning of a GridViewCommandRow... in this case I put in my RadGridView this

    do:
    GridViewCommandRow.IsEnabled="True"

    with an external row..that's totaly another thing..
  4. Michele
    Michele avatar
    426 posts
    Member since:
    Jun 2009

    Posted 23 Nov 2012 Link to this post

    any news on this?
    Thanks
  5. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 23 Nov 2012 Link to this post

    Hello Paolo,

    Assuming you were following an online example of ours I am not sure what went wrong. I may offer you my help in the following way :
    Please send me a runnable version of your implementation and I will tamper with the logic which inserts the "row" in the visual tree so that it does not hide the group panel. I will send back the updated version to you .

    *In order  to be able to attach your  project, please open a support ticket mentioning the ID of this thread ( 631324).

    All the best,
    Pavel Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top