filtring with one textbox.

Hi,

What if I wont to filter several columns or all columns with when value in an sfDataGrid;

Using contains and or. 

Ex: filter = “column1 like ‘*a*’ or column2 like ‘*a*’ or …”

One Textbox to filter all the dataset.

For GridGouptinControl i used this

 

private void filter_box_TextChanged(object sender, EventArgs e)
        {
            string filter = "";
            DataColumnCollection dataColumn = rhDataSet.Tables["rh"].Columns;
            RecordFilterDescriptor recordFilterDescriptor;
            gridG1.TableDescriptor.RecordFilters.Clear();


            int length = dataColumn.Count;
            if (filter_box.Text.Trim() != "")
            {
                for (int i = 0; i < length; i++)
                {
                    if (i > 0) filter += " or ";
                    filter += "[" + dataColumn[i].ColumnName + "]" + " like '*" + filter_box.Text.Trim() + "*'";
                }
            }
            try
            {
                recordFilterDescriptor = new RecordFilterDescriptor(filter);
                gridG1.TableDescriptor.RecordFilters.Add(recordFilterDescriptor);
            }
            catch (Exception ex)
            {
                Show(ex.Message);
            }
        }


thanks.



1 Reply 1 reply marked as answer

DM Dhanasekar Mohanraj Syncfusion Team April 1, 2022 02:15 PM UTC

Hi ehs psy,

Based on provided information we suspect that you need to filter all columns or any specific column based on single textbox text input. For this scenario we had attached a sample. Please check the sample in the attachment. If this doesn’t meet your requirement, please provide more information regarding your requirement with illustrations. It will be helpful for us to check the possibilities and to provide a prompt solution.

Regards,
Dhanasekar M.


Attachment: Filtering_9df64515.zip

Marked as answer
Loader.
Up arrow icon