Infragistics xamDataGrid 绑定到分层数据 - 如何通知第二级网格发生更改?
首先让我们想象一些域对象:
Customer:
Name
Phone
List of Orders
Order:
Date
Amount
然后使用以下字段集设置我的网格:
<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>
当我的客户列表预先填充了数据时,这可以正常工作。每个客户行都有一个 +,单击时,该行会展开以显示订单列表。
现在,所有美好的事情都结束了......
我们尝试使订单异步,这在用户展开行时给我们一个空集合。当异步调用完成时,集合会更新,但网格不会更新。
由于集合最初是空的,因此网格删除了 +,并且用户不再具有折叠/展开的能力。如果当用户第一次展开行时集合包含数据,则当我们向集合添加更多对象时网格需要更新。
这应该如何运作?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用 ObservableCollection 作为树结构中的节点集合。
Try to use ObservableCollection as collection of nodes in you tree-structure.
请尝试这个..它有效
首先,
在Xaml页面中
创建两个这样的类如果您想在加载时展开子列表,您可以尝试处理InitializeRecord事件并设置Record的IsExpanded属性:
Please try this..It works
First of all,Create two classes like this
In Xaml page
If you want to expand the child list on load,You can try handling the InitializeRecord event and set the IsExpanded property of the Record: