very slow for custom filtering in gridview

1 posts, 0 answers
  1. Hengky
    Hengky avatar
    18 posts
    Member since:
    Sep 2015

    Posted 01 Feb Link to this post

    Hello all 

    i have the problem about custom filtering ... 

    why custom filtering in gridview is very slowly 

    this the code i write 

     Imports System.Data.SqlClient

    Public Class Form1
        Dim conn As SqlConnection
        Dim da As SqlDataAdapter
        Dim ds As DataSet

        Dim str As String = "Server=CHIP-PC;Initial Catalog=Kebun;uid=sa;pwd=351980"

        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            Using conn As New SqlConnection(str)

                conn.Open()

                da = New SqlDataAdapter("SELECT * FROM MstPekerja", conn)
                ds = New DataSet
                ds.Clear()
                da.Fill(ds, "TrPekerja")
                RadGridView1.DataSource = (ds.Tables("TrPekerja"))

                conn.Close()
            End Using
        End Sub
        Private Sub RadGridview1_CustomFiltering(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCustomFilteringEventArgs) Handles RadGridView1.CustomFiltering
            If String.IsNullOrEmpty(Me.RadTextBox1.Text) Then
                e.Visible = True
                For i As Integer = 0 To Me.RadGridView1.ColumnCount - 1
                    e.Row.Cells(i).Style.Reset()
                    e.Row.InvalidateRow()
                Next i
                Return
            End If
            e.Visible = False
            For i As Integer = 0 To Me.RadGridView1.ColumnCount - 1
                Dim text As String = e.Row.Cells(i).Value.ToString()
                If text.IndexOf(Me.RadTextBox1.Text, 0, StringComparison.InvariantCultureIgnoreCase) >= 0 Then
                    e.Visible = True
                    e.Row.Cells(i).Style.CustomizeFill = True
                    e.Row.Cells(i).Style.DrawFill = True
                    e.Row.Cells(i).Style.BackColor = Color.FromArgb(201, 252, 254)
                Else
                    e.Row.Cells(i).Style.Reset()
                    e.Row.InvalidateRow()
                End If
            Next i
        End Sub

        Private Sub RadTextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles RadTextBox1.TextChanged
            Me.RadGridView1.MasterTemplate.Refresh()
        End Sub
    End Class

    i just set enablecustomfiltering = true 

    enable filtering = true 

     

     the data only 726 rows .... 

     

    Thanks n best regards 

     

    Hengky 

     

     

Back to Top