This project is read-only.

How can I handle the click event of button in drag a header column area

Mar 21, 2014 at 11:01 AM
Hi,

I want to add one button in the drag area and want to handle that how can i do that .

I had added this in Datagridgeneric.xaml

<DockPanel x:Name="PDFPanel" Grid.Row="0" LastChildFill="True" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1">
                                                <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
                                                    <Button x:Name="btnPlus" HorizontalAlignment="Right" VerticalAlignment="Top" Height="20" Width="20" Click="ExcelExportClick">
                                                        <Image Source="../Images/PlusSign.png" Height="20" Width="20" Stretch="UniformToFill" Margin="0,0,0,0"/>
                                                    </Button>


                                                </StackPanel>
                                            </DockPanel>
<!-- Column Header--> I can now view the button on that area but Cannot find the way to handle the click event in datagridgeneric.cs file
Mar 21, 2014 at 11:28 AM

Send me your complete code I might help u.

Mar 24, 2014 at 8:52 AM
I had added One button in the drag column header section

In Datagridgeneric.xaml

<StackPanel Orientation="Vertical" MinHeight="30" VerticalAlignment="Center" Visibility="{Binding RelativeSource={RelativeSource AncestorType=ExtendedGridControl:ExtendedDataGrid}, Path=GroupByControlVisibility}">
                                                        <TextBlock x:Name="txtDragName" Loaded="TxtDragLoaded" Visibility="Visible"  VerticalAlignment="Stretch" Padding="8">Drag a column header here to group by that column.</TextBlock>

                                                        <DockPanel LastChildFill="True"  HorizontalAlignment="Stretch">
                                                            <Button DockPanel.Dock="Right" Cursor="Hand" Margin="3" x:Name="btnClearGroup" Click="ClearGroupClick" VerticalAlignment="Center" HorizontalAlignment="Right" Visibility="Collapsed">
                                                                <Image Source="../Images/close.png" Height="12" Width="12"/>
                                                            </Button>
<Button DockPanel.Dock="Right" x:Name="btnPlus" HorizontalAlignment="Right" VerticalAlignment="Center" Height="20" Width="20" Click="AddNewClick" Margin="0,-30,10,0">
                                                                <Image Source="../Images/PlusSign.png" Height="20" Width="20" Stretch="UniformToFill" Margin="0,0,0,0"/>
                                                            </Button>
<ItemsControl DockPanel.Dock="Left" x:Name="group" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=ExtendedGridControl:ExtendedDataGrid}, Path=GroupByCollection}" HorizontalAlignment="Left" HorizontalContentAlignment="Left" VerticalAlignment="Stretch">
                                                                <ItemsControl.ItemTemplate>
                                                                    <DataTemplate>
                                                                        <StackPanel Orientation="Horizontal">

                                                                            <Grid HorizontalAlignment="Left" x:Name="Grid"  VerticalAlignment="Stretch" Width="{Binding GridWidth}">
                                                                                <Grid.RowDefinitions>
                                                                                    <RowDefinition Height="*"/>
                                                                                    <RowDefinition Height="*"/>
                                                                                </Grid.RowDefinitions>
                                                                                <Grid.ColumnDefinitions>
                                                                                    <ColumnDefinition Width="*"/>
                                                                                    <ColumnDefinition Width="{Binding GridSecondColumnWidth}"/>
                                                                                </Grid.ColumnDefinitions>
                                                                                <Border Grid.Row="0" Grid.Column="0" BorderThickness="0,0,1,0" BorderBrush="{DynamicResource DynamicGridLineColorBrush}">

                                                                                </Border>
                                                                                <Border Grid.Row="0" Grid.Column="1" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource DynamicGridLineColorBrush}">

                                                                                </Border>
                                                                            </Grid>
                                                                            <Primitives1:DataGridColumnHeader Width="Auto" Tag="{Binding SortDirection}" >
                                                                            </Primitives1:DataGridColumnHeader>
                                                                        </StackPanel>
                                                                    </DataTemplate>
                                                                </ItemsControl.ItemTemplate>
                                                            </ItemsControl>

                                                        </DockPanel>

I want to expose this button Click event to user so when the user clicks on this button . He can open the pannel . I am just including the extended grid.dll in our project and want to handle this event over there .
Mar 24, 2014 at 5:22 PM
First hook the event to DataGridGeneric.cs
Then from sender extract the grid (using FindControls class, you will find many example)
Expose one event in ExtendeDataGrid class
Call this event from the Datagrenric class
Mar 25, 2014 at 9:41 AM
This code added in Datageneric.xaml

<Button DockPanel.Dock="Right" x:Name="btnPlus" HorizontalAlignment="Right" VerticalAlignment="Center" Height="20" Width="20" Click="AddNewClick" Margin="0,-30,10,0">
<Image Source="../Images/PlusSign.png" Height="20" Width="20" Stretch="UniformToFill" Margin="0,0,0,0"/>
</Button>

This code added in DatagridGeneric.cs

private void AddNewClick(object sender, RoutedEventArgs e)
         {
             var btnPlus = sender as FrameworkElement;
             var grid = FindControls.FindParent<ExtendedDataGrid>(btnPlus);
             if (grid != null)
             {
                 grid.RaiseRowEvent();
             }

         }
This code added in ExtendedGrid.cs
public static readonly RoutedEvent AddEvent = EventManager.RegisterRoutedEvent(
   "AddRowEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ExtendedDataGrid));

    // Provide CLR accessors for the event 
    public event RoutedEventHandler AddRowEvent
    {
        add { AddHandler(AddEvent, value); }
        remove { RemoveHandler(AddEvent, value); }
    }

    // This method raises the Tap event 
    public void RaiseRowEvent()
    {
        RoutedEventArgs newEventArgs = new RoutedEventArgs(ExtendedDataGrid.AddEvent);
        RaiseEvent(newEventArgs);
    }

I added this code for the same . But Still I am not Getting the event . I suppose I had to Do something in Datagridgenric.xaml to get that event to Get that event When I reference to the dll
Mar 25, 2014 at 9:52 AM

Let me check
Will revert back in 12 he's

I hope you have subscribed to the even?

Apr 7, 2014 at 12:26 PM
Hi Did you get the chance to see
Apr 7, 2014 at 6:06 PM
Hi,

From the only the cod epices it looks ok to me , but hard to understand if it would work.
you have not sent me working pilot project until that I cannot comment.

Its really hard for me to work on special request because this would be useful only for you.
Apr 8, 2014 at 11:19 AM
Thanks for your help . It worked that way but While implementing this it was showing error . And at runtime I was able to get that Event.

Regards
Lucky Ahuja