This example shows how to return the collection of visible rows to the ViewModel. For more details, refer to the KA18591: How to synchronize filtered data between the GridControl and ViewModel KnowledgeBaseArticle.
Question Comments
Added By: Kerry Patrick at: 7/23/2014 8:31:53 AM
Hello.
Thank you so much for this example. One problem I encounter when using this code is when I have a GridColumn which uses a custom binding because it relies on an IValueConverter. For example:
<dxg:GridColumn UnboundType="String" Binding="{Binding ItemizedInstruments, Converter={StaticResource ListHasItemsToYesNoConverter}}" Header="Itemized?" ReadOnly="True" Width="Auto" >
</dxg:GridColumn>
After poking around a little bit in the visible object model, it appears that the list of visible row handles can be obtained in the OnFilterChanged event by querying grid.DataController.FilterHelper.VisibleListSourceRows.ToArray(). You can then loop through the handles and call visibleData.Add(grid.GetRow(handle)) to get the collection of visible objects. Can you tell me if this is also an acceptable way to keep the visible objects in sync between the view model and the GridControl, or are there pitfalls to this approach?
Kindest regards,
Kerry