On initial load check if column is filtered

Hello,

On initial load of the page i would like to check if a particular column is filtered.

For example 

    protected override async Task OnInitializedAsync()
    {
if(check if column 'orders' has filter applied){
isFiltered= true;
}


    }

3 Replies 1 reply marked as answer

KG Keerthana Ganesan Syncfusion Team August 18, 2022 03:45 PM UTC

Hi Pavel,


Greetings from Syncfusion support.


We have analyzed your query and we suggest you use the FilterSettings grid instance to get the filtered columns. Kindly refer to the attached code snippet for your reference.


protected override void OnInitialized() {

var IsfilterCount = Grid.FilterSettings.Columns.Count();

        if (IsfilterCount >= 0)

        {

            bool Isfilter = true;

        }

}


Please get back to us if you have any further queries.


Regards,

Keerthana.



PA Pavel August 18, 2022 04:08 PM UTC

Thank you that does help to check if ANY columns in the have filter.

How about a specific column?

For example if I have 3 columns 

1.city 

2.state 

3.country

How do I check if City column is filtere



SP Sarveswaran Palani Syncfusion Team August 22, 2022 04:03 PM UTC

Hi Pavel,


Thanks for contacting Syncfusion support again.


We have analyzed your query and filtered particular column in OnLoad event by assigning bool value true to filtered value. Kindly refer the attached code snippet and sample for your reference.


public void LoadHandler(object args) {

 

    var IsfilterCount = Grid.FilterSettings.Columns;

 

        if (IsfilterCount.Count > 0)

        {

            for(var i = 0; i < IsfilterCount.Count;i++)

            {

                if( "CustomerID" == IsfilterCount[i].Field)

                {

                    bool Isfilter = true;

                }

            }

        }

    }


Kindly get back to us if you have any further queries


Regards,

Sarveswaran PK


Attachment: SfGridFilterColumn_550d481b.zip

Marked as answer
Loader.
Up arrow icon