Preserve filter after data source change (multi column)

Posted by: milosic.bogdan on 13 February 2018, 5:40 pm EST

    • Post Options:
    • Link

    Posted 13 February 2018, 5:40 pm EST

    I have problem with preserving filter after datasource refresh.

    I set filter on column 1 DataGridTextColumn for 123 and set it for later

    global variable:

    
    
    dim fil
    
    
    

    before datasource change

    
    fil = grdPreview.Columns(0).FilterState
    
    

    and

    after i change datasource i can set filter back with

    
    grdPreview.FilterBy(grdPreview.Columns(0), fc)
    
    

    How can i set filter for multiple columns?

    I tried with:

    global variable

    
    dim fill
    
    

    Before datasource change:

    
    fil = New List(Of DataGridFilterState)
    
                For Each col In grdPreview.Columns
                    fil.add(grdPreview.Columns(col.Index).FilterState)
                Next
    
    

    and after datasource change

    
    Dim ii As Integer = 0
    
                For Each fc In fil
    
                    If Not fc Is Nothing Then
                        grdPreview.FilterBy(grdPreview.Columns(ii), fc)
                    End If
    
                  
    
                    ii = i + 1
                Next
    
    
    

    It filters only last condition.

    How can i filter by all conditions?

    I have read but i dont know how to fill paramarray.

  • Posted 13 February 2018, 6:41 pm EST

    I think i managed it now, i just add preserve previous onTrue

    
    
     grdPreview.FilterBy(grdPreview.Columns(ii), fil(ii), True)
    
    
    
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels