This is a migrated thread and some comments may be shown as answers.

Filtering ListView

6 Answers 522 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Tino
Top achievements
Rank 1
Tino asked on 17 May 2018, 06:10 AM

Quick question about filtering. I have a ListView with several columns including a checkbox column. I want to filter the listview on one column ("Title'), based on a textbox value as the user types. I thought the below might work, but it doesn't seem to work, the filtering doesn't look right. Please tell me why this approach doesn't work. Thanks.

Code to add the filter:

private FilterDescriptor _valueFilter;
_valueFilter = new FilterDescriptor("Title", FilterOperator.Contains, "");
lstvwLookups.FilterDescriptors.Add(_valueFilter);

 

Code to update the filter:

private void txtFilter_TextChanged(object sender, EventArgs e)
{
    _valueFilter.Value = ((TextBoxChangedEventArgs)e).Text;
}

6 Answers, 1 is accepted

Sort by
0
Tino
Top achievements
Rank 1
answered on 17 May 2018, 06:28 AM
Never mind, I found the error. I was filtering on e.Text instead of sender (as RadTextBoxControl) Text.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 May 2018, 12:53 PM
Hello, Tino,     

I am glad that the problem you were facing is now resolved. Additional information about the filtering functionality in RadListView is available in the following help article: https://docs.telerik.com/devtools/winforms/listview/features/filtering

You can also have a look at the Demo application >> ListView >> First look example which provides a filter box as well.

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Tino
Top achievements
Rank 1
answered on 17 May 2018, 10:00 PM
Thanks yes I saw that of course but it doesn't show a filter-as-you-type sample which is what I was after.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 21 May 2018, 11:46 AM
Hello, Tino,     

In the Demo application >> ListView >> First look example there is a filter box which demonstrates a filter as you type example which uses the FilterDescriptor instance to perform filtering. 

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Arun
Top achievements
Rank 2
Iron
answered on 08 Feb 2021, 09:59 AM

Hi, 

I have tried this following code to filter the listview on Enter event of the textbox. But it's not filtering. Can you please help to resolve please?

Private Sub radTxtSearch_KeyDown(sender As Object, e As KeyEventArgs) Handles radTxtSearch.KeyDown
        If e.KeyCode = Keys.Enter Then
            radLstDetails.EnableFiltering = True
            Dim typeFilter As New FilterDescriptor("Column 4", FilterOperator.Contains, radTxtSearch.Text)
            radLstDetails.FilterDescriptors.Add(typeFilter)
            radLstDetails.ListViewElement.DataView.Refresh()
        End If
    End Sub
1
Dess | Tech Support Engineer, Principal
Telerik team
answered on 09 Feb 2021, 08:27 AM

Hello, Arun,  

Following the provided code snippet I have prepared a sample project to test the behavior on my end. Filtering RadListView works as expected. Please refer to the attached gif file. However, I have added clearing the FilterDescriptors collection before adding a new FilterDescriptor.

Please give the attached sample project a try and see how it works on your end.

I hope this information helps. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
ListView
Asked by
Tino
Top achievements
Rank 1
Answers by
Tino
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Arun
Top achievements
Rank 2
Iron
Share this question
or