RadGridView Filter Default Selection

4 posts, 0 answers
  1. Ilkka
    Ilkka avatar
    2 posts
    Member since:
    Mar 2013

    Posted 19 Mar 2013 Link to this post

    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!
  2. Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 22 Mar 2013 Link to this post

    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.
  3. Ilkka
    Ilkka avatar
    2 posts
    Member since:
    Mar 2013

    Posted 22 Mar 2013 Link to this post

    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
  4. Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 22 Mar 2013 Link to this post

    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.
Back to Top