This is a migrated thread and some comments may be shown as answers.

GridViewCommandRow and Grouping

4 Answers 40 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 2
Michele asked on 19 Nov 2012, 02:38 PM
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

4 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 19 Nov 2012, 02:57 PM
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.

0
Michele
Top achievements
Rank 2
answered on 19 Nov 2012, 03:13 PM
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..
0
Michele
Top achievements
Rank 2
answered on 23 Nov 2012, 08:11 AM
any news on this?
Thanks
0
Pavel Pavlov
Telerik team
answered on 23 Nov 2012, 11:13 AM
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.

Tags
GridView
Asked by
Michele
Top achievements
Rank 2
Answers by
Pavel Pavlov
Telerik team
Michele
Top achievements
Rank 2
Share this question
or