Search code examples
data-bindinginfragistics

Infragistics xamDataGrid bound to hierarchical data - how to notify grid of changed in second level?


Lets first imagine some domain objects:

Customer:
  Name
  Phone
  List of Orders

Order:
  Date
  Amount

My grid is then set up with the following field sets:

<XamDataGrid>
  <XamDataGrid.FieldLayouts>
    <FieldLayout Key="Customers">
      <Field Name="Orders" IsExpandable="True" />
      <Field Name="Name" />
      <Field Name="Phone" />
    </FieldLayout>
    <FieldLayout ParentFieldLayoutKey="Customers">
      <Field Name="Date" />
      <Field Name="Amount" />
    </FieldLayout>
  </XamDataGrid.FieldLayouts>
</XamDataGrid>

This works fine when my list of customers are pre-populated with data. Each customer row gets a +, and when clicked, the row expands to show the list of orders.

Now, all good things comes to an end...

We tried to get the orders async, which gives us an empty collection when the user expands the row. When the async call finish, the collection is updated, but the grid wont update.

Since the collection initially is empty, the grid removes the +, and the user no longer has the abillity to collaps/expand. If the collection contains data when the user first expands the row, the grid want update if we add more objects to the collection.

How is this supposed to work?


Solution

  • Try to use ObservableCollection as collection of nodes in you tree-structure.