views:

692

answers:

2

I have a DataGrid (from the toolkit) and I want to nest another DataGrid in the DataGrid.RowDetailsTemplate. The trick is I want to bring back the data from one table in the main grid and then based on row selection go and get additonal detail from a different table and show it in the DataGrid in the detail template.

This is easy enough to do in 2 seperate DataGrids but I am having trouble getting it to work with the nested version.

Is this even possible? If so, could someone point me in the right direction. I should note I am using LinqToSql clases to populate the data.

Thanks for your consideration. -Joel

A: 

I'd appreciate guidance on this too

jdk
A: 

If you are using LinqToSQL you can easily do this using an association. In my practice I have created two tables:

GuyTable

  • First Name
  • Last Name
  • UniqueID

GuyActionsTable

  • UniqueID
  • GuyID
  • Action Description

I created a one-to-many relationship from GuyTable.UniqueID to GuyActionsTable.GuyID called "GuyActions"

I then bind my DataGrid like this. Excuse any errors as I am doing this by hand:

<w:DataGrid ItemsSource={Binding Source={StaticResource YourDataSource}}>
<w:DataGrid.RowDetailsTemplate>
 <DataTemplate>
  <w:DataGrid ItemsSource={Binding GuyActions}>
   <w:DataGrid.Columns>
    <w:DataGridTextColumn Header="Action" DisplayMemberBinding="{Binding Action_Description}" />
   </w:DataGrid.Columns>
  </w:DataGrid>
 </DataTemplate>
</w:DataGrid.RowDetailsTemplate>
<w:DataGrid.Columns>
 <w:DataGridTextColumn Header="First Name" DisplayMemberBinding="{Binding First_Name}" />
 <w:DataGridTextColumn Header="Last Name" DisplayMemberBinding="{Binding Last_Name}" />
</w:DataGrid.Columns>

masenkablast