Home Forums WPF controls Xceed DataGrid for WPF Insertion Row on Details in Master Detail Grid

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #27029 |

    Hi

    I’ve looked through many many posts on this forum but I’m not getting the answer I’m looking for. (I suspect I’m missing something obvious)

    I’ve got a Master Detail grid bound to Linq Bindinglists. When a row is inserted to the grid, I want to manualy write the row data back to our system via a web service call. I’m successfully doing this on the master section, by overriding the InsertionRow OnEndingEdit event, and then simply taking the last element in the Master BindingList as the item I need to write back to our system. This might not be the most elegant, but it works.

     On the insertion row in the details section I have a problem: I can no longer just take the last item in the bindinglist. I need to find the item that was added, and I also need to know to which item from the master section grid it was added. I don’t see an easy way to find a reference to the item that was just added  (or the item that will be added depending on which event you handle).

    Jenny, from your other posts it seems like the loaded event on the InsertionRow might be of use, but I don’t see how? I don’t see how a reference to the InsertionRow itself or the parent grid will help?

    Thanks! 

     

     

    Imported from legacy forums. Posted by Henry (had 3786 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Henry,

    The InsertionRow’s DataContext is the System.Data.DataRow (assuming you are using DataTables, otherwise use whatever the type of your data item is). Therefore, you could handle the DetailConfiguration.InitializingInsertionRow event and get the data item there. Something like this:

    <xcdg:DataGridControl.DetailConfigurations>
      
    <xcdg:DetailConfiguration InitializingInsertionRow=”OnInitializingInsertionRow”
                                            
    RelationName=”Employee_Orders”>
         
    <xcdg:DetailConfiguration.Headers>
            
    <DataTemplate>
               
    <xcdg:InsertionRow />
            
    </DataTemplate>
         
    </xcdg:DetailConfiguration.Headers>
      
    </xcdg:DetailConfiguration>
    </xcdg:DataGridControl.DetailConfigurations>

    private void OnInitializingInsertionRow( object sender, InitializingInsertionRowEventArgs e )
    {
       System.Data.
    DataRow row = e.InsertionRow.DataContext as System.Data.DataRow;
    }

    Imported from legacy forums. Posted by Jenny [Xceed] (had 1344 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Jenny

    Again you save me from certain insanity!

    That works. Thank you very much.

    Henry

    Imported from legacy forums. Posted by Henry (had 760 views)

    User (Old forums)
    Member
    Post count: 23064

    I’m not sure how this post helped Henry, as it is not working for me.

    I’ve got the same exact problem.  I need to access the parent object when the InsertionRow is used, in order to properly the new child object.  The parent object is absolutely essential to properly creating the child object.

     I created the above event handler code in the C# codebehind, and wired up the XAML similar to above, but the event does not fire prior to the grids InitializeNewItem or CreatingNewItem events, so this event handling is useless to me.

     How can I access the parent (or Master) object from the InitializeNewItem or CreatingNewItem events?  Please don’t tell me to look at the DataGrid.SelectedItem or DataGrid.GlobalCurrentItem, as a different parent row could be selected than the parent row that is expanded and had a double click happen in the DetailConfiguration’s insertion row.

     Thanks in advance….

    Imported from legacy forums. Posted by Ryan (had 4170 views)

    Xceed Support
    Member
    Post count: 5658

    Ryan, I replied to your question in this post: http://xceed.com/CS/forums/thread/12262.aspx

     

    Imported from legacy forums. Posted by Jenny [Xceed] (had 2960 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.