This is a migrated thread and some comments may be shown as answers.
RadGridView Filter Default Selection
3 Answers 90 Views
This is a migrated thread and some comments may be shown as answers.
Ilkka
Top achievements
Rank 1
Ilkka asked on 19 Mar 2013, 11:20 AM
Hi,

I have question about the filter default selection. Now there is no filter for gridview rows when the Form is opened (all checkboxes are checked for each filter so there is no filter)

I have read that on the WPF side there is FilterOperatorsLoading event where you can change this default filter selection but on WinForms side does not have that event?

So what is the correct way to access/modify filters before the form/gridview is shown for the first time?

I am using VB.NET, Thanks!

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 22 Mar 2013, 08:55 AM
Hi llkka,

Thank you for writing.

To filter RadGridView for WinForms, you just need to add the desired FilterDescriptors to it. A sample of this is available in our online documentation: http://www.telerik.com/help/winforms/gridview-filtering-setting-filters-programmatically-simple-descriptors.html.

I hope this helps.
 

Regards,
Stefan
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
0
Ilkka
Top achievements
Rank 1
answered on 22 Mar 2013, 11:09 AM
Hi,

What is the correct place to create FilterDescriptors? I have tried to do it in Form Load eventhandler or Form Shown eventhandler but I can't get it working.

Could you provide an exanple code (Winforms) where radgridview filter selection are set before the Form/radgridview is loaded or shown?
My radgridview Datasource is Datatable and it is filled in Form Load method.

Br,
Ilkka
0
Stefan
Telerik team
answered on 22 Mar 2013, 01:30 PM
I sure can. Here you are:
Imports Telerik.WinControls.Data
 
Public Class Form1
 
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        BindGrid()
 
        RadGridView1.EnableFiltering = True
 
        Dim filter As New FilterDescriptor()
        filter.PropertyName = "ID"
        filter.[Operator] = FilterOperator.IsGreaterThan
        filter.Value = 3
        filter.IsFilterEditor = True
        Me.RadGridView1.FilterDescriptors.Add(filter)
 
        Dim filter2 As New FilterDescriptor()
        filter2.PropertyName = "Bool"
        filter2.[Operator] = FilterOperator.IsEqualTo
        filter2.Value = True
        filter2.IsFilterEditor = True
        Me.RadGridView1.FilterDescriptors.Add(filter2)
 
 
    End Sub
    Private Sub BindGrid()
        Dim r As New Random()
        Dim table As New DataTable()
        table.Columns.Add("ID", GetType(Integer))
        table.Columns.Add("Name", GetType(String))
        table.Columns.Add("Bool", GetType(Boolean))
 
        For i As Integer = 0 To 9
            table.Rows.Add(i, "Row " & i, If(r.[Next](10) > 5, True, False))
        Next
 
        Me.RadGridView1.DataSource = table
 
    End Sub
End Class

 

Kind regards,
Stefan
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
Asked by
Ilkka
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Ilkka
Top achievements
Rank 1
Share this question
or