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

How to pass parameter to event LoadingRowDetails (Hierarchical View)

3 Answers 217 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mateusz
Top achievements
Rank 1
Mateusz asked on 22 Dec 2017, 08:58 AM

Hello,

 

This is my first post here and I sense that it's not last, due to your unhelpfull documentation and demos. I have RadGridView with data bound. Everything is connected to ADO and dynnamically loaded and refreshed. Also, I can pass parameter of my gridView.SelectedItem to Linq query, to retrieve the data. What I want to do is pass parameter of expanted data. For full clarification:

1. After I press "+" button my row is expanding to row details

2. I have 2 tabs there, 1st is a simple grid, 2nd is a grid view with table.

3. I need to pass parameter (Id of row I'm expanding) to query. 

 

As I mentioned, my connection and data binding works, because I can achieve this by using SelectedItem property. The problem is that, SelectedItem property passes Id of selected item, not expanded one, which means I can pass id of another item, to my expanded item. All I need here is to get something like "ExpandedItem" property, how do I get it?

 

XAML

<Grid>
        <telerik:RadGridView  x:Name="ListaProduktow" GroupRenderMode="Flat"
                                  CanUserFreezeColumns="False"
                                  RowIndicatorVisibility="Collapsed"
                                  ItemsSource="{Binding}"
                                    AutoGenerateColumns="False"
                              ShowGroupPanel="False"
                              FilteringMode="Popup"
                              ShowSearchPanel="True"
                              IsSearchingDeferred="True"
                              AlternationCount="2"
                              LoadingRowDetails="SzczegolyClick"
                             >
 
        <telerik:RadGridView.Columns>
 
            <telerik:GridViewToggleRowDetailsColumn />
 
                <telerik:GridViewDataColumn Header="Departament" TextWrapping="Wrap"
                                                DataMemberBinding="{Binding Departament}"
                                            Width="100"
                                            IsReadOnly="True"
                                            />
 
...OTHER COLUMNS...
 
 
            </telerik:RadGridView.Columns>
            <telerik:RadGridView.RowDetailsTemplate>
                <DataTemplate>
                    <telerik:RadTabControl x:Name="SzczegolyForm"
                                           Width="702"
                                           HorizontalAlignment="Left"
                                           Margin="8"
                                           VerticalAlignment="Center"
                                          >
...1st TAB...
 
 </telerik:RadTabItem>
                        
                            <telerik:RadTabItem Header="Stany Magazynowe"
                                                TabIndex="2"
                                               >
                            <telerik:RadGridView
                                                 Width="Auto"
                                                 HorizontalAlignment="Stretch"
                                                 IsReadOnly="True"
                                                 ShowGroupPanel="False"
                                                 AutoGenerateColumns="False"
                                                ItemsSource="{Binding StanyMagazynowe}"
                                                Name="StanyMagazynoweForm">
                                <telerik:RadGridView.Columns>
                                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Magazyn}"
                                                                Header="Kod Magazynu" />
                                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Ilość}"
                                                                Header="Ilość" />
                                </telerik:RadGridView.Columns>
                            </telerik:RadGridView>
                        </telerik:RadTabItem>
                        </telerik:RadTabControl>
                </DataTemplate>
            </telerik:RadGridView.RowDetailsTemplate>
        </telerik:RadGridView>
</Grid>

 

Code behind:

 

  private void SzczegolyClick(object sender, GridViewRowDetailsEventArgs e)
       {
           WarehouseDetails();
           ListaProduktow.ItemsSource = products;
       }
 
private void WarehouseDetails()
       {
           string productId;
           var selectedProduct = ListaProduktow.SelectedItem as V_PRODUCTS_LIST;
           
           if (selectedProduct != null)
           {
               productId = selectedProduct.Id_Product;
               selectedProduct.StanyMagazynowe = products.Where(e => e.Id_Product == productId).Select(product =>
                   new StanyMagazynowe()
                   {
                       Magazyn = product.Magazyn,
                       Ilość = product.Ilość
                   }).ToList();
           }
      
           
       }

3 Answers, 1 is accepted

Sort by
0
Accepted
Yoan
Telerik team
answered on 26 Dec 2017, 08:37 AM
Hello,

You can use GridView's LoadingRowDetails event which is raised when you press the "+" button. The "Row" event argument should be suitable for you. Please check the following code snippet for a reference:
private void clubsGrid_LoadingRowDetails(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e)
        {
            var theObjectBehindTheExpandedRow = e.Row.Item;
        }

I hope this helps.

Regards,
Yoan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Mateusz
Top achievements
Rank 1
answered on 27 Dec 2017, 08:08 AM
Yes, it does, thanks. I wish there was a documentation for that.
0
Yoan
Telerik team
answered on 27 Dec 2017, 10:35 AM
Hello,

I am glad to hear that. We will update our documentation asap.

Regards,
Yoan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Mateusz
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Mateusz
Top achievements
Rank 1
Share this question
or