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

Toggle RowDetails Column click event

8 Answers 310 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sam Ur
Top achievements
Rank 2
Sam Ur asked on 01 Sep 2010, 07:20 AM
Hi,
I have a question on how can i get a click event for Toggle RowDetails Column ([+] button in this column). I tried to use Button.Pase and add event through that...but it's not working as i expected.

8 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 01 Sep 2010, 07:30 AM
Hello Sam Ur,

 You may try to use the IsExpandedChanged event of the GridViewRow.

Greetings,
Maya
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
0
Sam Ur
Top achievements
Rank 2
answered on 06 Sep 2010, 01:49 PM
Hi,
sorry for the late reply. I tried to use event you suggested but it's not working as i hoped.
I still have to first select a row and then click toggle button to see the changes i want.
0
Rossen Hristov
Telerik team
answered on 06 Sep 2010, 01:57 PM
Hi Sam Ur,

You have three options:

1. You can attach to the RowDetailsVisibilityChanged event of RadGridView. For more information, please consult the docs.

2. You can inherit from GridViewToggleRowDetailsColumn and override its CreateCellElement. Call the base implementation and it will return the toggle button. Attach to its Click event and return it.

3. Alternatively, you can create your very own toggle column and have full control over what is going on. This is demonstrated in my blog post.

I hope this helps.

All the best,
Ross
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
0
Sam Ur
Top achievements
Rank 2
answered on 06 Sep 2010, 07:33 PM
Hi Ross,
I created another class:
class MyToggleButton:GridViewToggleRowDetailsColumn
    {
        public GridViewCell cell { get; set; }
        public object dataItem { get; set; }
        public MyToggleButton()
        {
            this.ExpandMode = GridViewToggleRowDetailsColumnExpandMode.Single;
        }
        public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
        {
            this.cell = cell;
            this.dataItem = dataItem;
            GridViewToggleButton gwtb = new GridViewToggleButton()
                                            {
                                                Command = RadGridViewCommands.ExpandHierarchyItem,
                                                CommandParameter = dataItem
                                            };
            return gwtb;
        }
        void gwtb_Click(object sender, RoutedEventArgs e)
        {
        }
    }
But i don't know...now i cannot get details rows to show on my main grid...I also changed code in my xaml...
...
<
my:MyToggleButton x:Name="toggleButton" />
I don't know where I'm stuck.
0
Accepted
Rossen Hristov
Telerik team
answered on 07 Sep 2010, 08:01 AM
Hi Sam Ur,

Please, use one of the other two approaches then.

Kind regards,
Ross
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
0
Sam Ur
Top achievements
Rank 2
answered on 07 Sep 2010, 08:28 PM
Thank you Ross,
basically i went into completely different way - hierarchy templates did the trick...sorry to bodder you but again
thank you for your help!


0
kedarnath
Top achievements
Rank 1
answered on 19 May 2011, 01:37 PM
Dear Sam ur


I hope u got the solution for handling the  row detail toggle button click event...


Could u please post that code....

I have been searching for the same.....

Thanx in advance...
0
Sam Ur
Top achievements
Rank 2
answered on 03 Jun 2011, 02:18 PM
Hi sorry for such a later reply...but like i said i used hierarchy template to solve my issue.

<telerik:RadGridView Name="myGrid" ButtonBase.Click="myGrid_Click" IsReadOnly="True"  Grid.Row="1" RowDetailsVisibilityMode="Collapsed" ItemsSource="{Binding Source={StaticResource DataSource}, Path=myData}" DataLoadMode="Synchronous" SelectionMode="Extended" ShowGroupPanel="False" HorizontalAlignment="Left" Margin="15,12,0,0" VerticalAlignment="Top" Height="638" Width="996" AutoGenerateColumns="False" >
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewToggleRowDetailsColumn />
                            <telerik:GridViewSelectColumn Name="grdCheckBox" />
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Title}" UniqueName="Title" Header="Title" />
</telerik:RadGridView.Columns>
<telerik:RadGridView.RowDetailsTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition />
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="150" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Text="Page:" />
                                    <TextBlock Text="{Binding Path=WebURL}"  />
                                </Grid>
                            </DataTemplate>
                        </telerik:RadGridView.RowDetailsTemplate>
                    </telerik:RadGridView>

But basically i used ButtonBase.Click Routed event and then in code behind wrote something like that...

private void grdKontakti_Click(object sender, RoutedEventArgs e)
        {
            if (e.OriginalSource.GetType() == new GridViewToggleButton().GetType())
            {
                //your code to handle togglebutton click...
            }
        }


Well hope it helped...at least a bit.

Tags
GridView
Asked by
Sam Ur
Top achievements
Rank 2
Answers by
Maya
Telerik team
Sam Ur
Top achievements
Rank 2
Rossen Hristov
Telerik team
kedarnath
Top achievements
Rank 1
Share this question
or