Inside Man
Inside Man

Reputation: 4372

Custom Filtering On CheckBox Check Changed - Telerik RadGrid Winforms

I have a Rad Grid which will fill from database. I have a check box which will filter some rows in its checked mode. I have a list of strings which contains some specific IDs.

Here is the Grid:

ID     Name
------------
1      John
2      Steve
3      Joe
4      Sara

Here is the List of strings:

"2","4"

I need when the checkbox is checked filter those rows which their ID exists in this list.

private void checkMajor_CheckStateChanged(object sender, EventArgs e)
{
    if (checkMajor.Checked)
        // Here will be the custom filter
    else
        this.gridShopList.Columns["IDCol"].FilterDescriptor = new FilterDescriptor();
}

How to do such thing? and more over How to make complex Custom Filtering on rows?

Upvotes: 0

Views: 761

Answers (1)

checho
checho

Reputation: 3120

Here you can see how to filter the grid by more then one condition: CompositeFitlerDescriptor

Here is a sample:

        List<string> list = new List<string>() {"2", "4"};

        CompositeFilterDescriptor compositeFilter = new CompositeFilterDescriptor();
        compositeFilter.LogicalOperator = FilterLogicalOperator.Or;

        foreach (var item in list)
        {
            compositeFilter.FilterDescriptors.Add(new FilterDescriptor("ID", FilterOperator.IsEqualTo, item));
        }

        this.radGridView1.Columns["IDCol"].FilterDescriptor = compositeFilter;

Upvotes: 1

Related Questions