Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
70
How can I properly filter a grid with hierarchical data using only a single top level filter row?
posted

I am using xamdatagrid v18.2.

I have a grid that contains hierarchical data.  A sample grid is below:

OrderID OrderCategory Size Quantity
       
Order1      
  Cat1    
    small 3
    medium  5
  Cat2    
    large 1
Order2      
  Cat3    
    small 7
Order3      
  Cat1    
    large 2
    extralarge 7

Now here are some examples of what I am looking to achieve.  When I set a value in the top level filter any any row satisfies the filter criteria I want the entire order to remain visible.

Filter OrderCategory="Cat1":

OrderID OrderCategory Size Quantity
  Filter = Cat1    
Order1      
  Cat1    
    small 3
    medium  5
  Cat2    
    large 1
Order3      
  Cat1    
    large 2
    extralarge

7

Filter Size="small":

OrderID OrderCategory Size Quantity
    Filter=small  
Order1      
  Cat1    
    small 3
    medium  5
  Cat2    
    large 1
Order2      
  Cat3    
    small 3

Filter Quantity="7":

OrderID OrderCategory Size Quantity
      Filter=7
Order2      
  Cat3    
    small 7
Order3      
  Cat1    
    large 2
    extralarge 7

Note that even if one child row at any level matches the filter, the entire order is visible.

Can you please provide a sample solution for this?

Thanks.

Parents
No Data
Reply
  • 34430
    Offline posted

    Hello TK,

    I have been investigating into your requirement in this case, and from the layout of your grid, I have to wonder if you should really be using the XamTreeGrid in this case instead of the XamDataGrid? From your diagram, it looks like you are basically using a single FieldLayout for all of your records, and if so, I would recommend using the XamTreeGrid as this may allow you to achieve your requirement more easily.

    With the above said, the closest filter option that we have to what you are describing in this case is if you set the XamTreeGrid.FieldLayoutSettings.FilterAction property to “ReduceOpacity.” This will reduce the opacity on any records that do not satisfy the filter that you have typed, but it will still keep them visible to the user. The issue with this with your requirement is that if an order does not at all satisfy the filter requirement, it will not be filtered out – it will just have all of its record’s opacities changed.

    I am attaching a sample project that demonstrates a layout like the one you have diagrammed in this thread using the XamTreeGrid with a FilterAction of “ReduceOpacity.”

    If you are looking for the ability to have your filters do exactly what you had described, the best thing I can recommend is to filter your grid manually. You can do this by setting the FilterAction to “None” or “DoNothing” and then handle the RecordFilterChanged event on the grid. Using the event arguments of the RecordFilterChanged event, you can obtain the filter that is applied and run some logic against your underlying data source to add or remove records from the grid.

    Please let me know if you have any other questions or concerns on this matter.

    XDGHierarchicalFilteringDemo.zip

Children
No Data