Dim strProp As String = "Select * from " & ViewName
Dim daProp As New OleDb.OleDbDataAdapter(strProp, conNFAD_NEW)
Dim dsProp As New DataSet
daProp.Fill(dsProp, "dtProp")
rgvMain.DataSource = dsProp.Tables("dtProp")
(rgvMain) being the radgridview
The query returns 31 000 records (8 columns). It takes about 10 seconds to load.
--------------
I tried instead of doing "select * from" to do a "select top 500". But when you filter the radgridview it filters the 500 records it returned form the query not the 31 000. which is correct.
But:
Is there a way to re-query the grid when a filter is applied so that it would return the top 500 records with the applied filter.
Thanks,
Goran Djuric
11 Answers, 1 is accepted
Thank you for writing us.
We did several tests with RadGridView. We bound the grid to a DataTable containing 50000 rows and 10 columns. The average result was 2.5 seconds load time. Please, could you measure the time when the DataSource property is set after calling the Fill method of your DataAdapter. It is possible that the Fill method needs some time to connect to the SQL server and fill its data.
Currently, we are revising the RadGridView data layer and will optimize the load time in our upcoming release Q1 2008.
Do not hesitate to contact us if you need further assistance.
All the best,
Jack
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
HI Jack,
ViewName =
"srcProperty"
Dim strProp As String = "Select * from " & ViewName
Dim daProp As New OleDb.OleDbDataAdapter(strProp, conNFAD_NEW)
Dim dsProp As New DataSet
Dim ds1 As DateTime = DateTime.Now
daProp.Fill(dsProp, "dtProp")
Dim ds2 As DateTime = DateTime.Now
Dim rgv1 As DateTime = DateTime.Now
rgvMain.DataSource = dsProp.Tables("dtProp")
Dim rgv2 As DateTime = DateTime.Now
Dim dgv1 As DateTime = DateTime.Now
dgvMain.DataSource = dsProp.Tables("dtProp")
Dim dgv2 As DateTime = DateTime.Now
Dim strMsg As String = "dsLoad = " & ds2.Subtract(ds1).ToString & vbNewLine
strMsg += "rgvMain = " & rgv2.Subtract(rgv1).ToString & vbNewLine
strMsg += "dgvMain = " & dgv2.Subtract(dgv1).ToString
rgvMian = rad grid view
dgvMain = data grid view
"THE Message:
dsLoad = 00.00.06.2063804
rgvMain = 00.00.05.8468168
dgvMain = 00.00.00.0781660
-----------------------------
I was wondering would it be possible to do the following:
In the rgvMain.FilterChanged event:
---
For i As Integer = 0 To rgvmain.columns.count - 1
If CType(Me.rgvmain.mastergridviewtemplate.colmns(i), gridviewdatacolumn).filter.stringvalue <> vbnullstring Then
msg += COLUMN NAME
msg += " like/= etc.. "
msg += CType(Me.rgvmain.mastergridviewtemplate.columns(i), gridviewdatacolumn).filter.stringvalue
End If
Next
-----
So when ever the filters change, I would get the filter string value and the databse column name. I would re - query the datagrid to select the top 500 records based on the filter value. This will bring down the time the data set takes to load, and the time the rad grid view takes to load. Do you think someting like this would be possible ?
Thank You,
Goran Djuric
You can implement this approach, but this will not decrease the load time of RadGirdView. For the new edition of RadGridView we have made more improvements for loading/showing/updating of data. The beta release will be available next week at the latest.
Currently, you can filter data in your SQL query or filter DefaultView of DataTable object and bind it to the RadGridView. Also you can bind a DataTable object to a BindingSource object, setup its Filter property and then bind to RadGridView.
I hope this was helpful. Contact me with any further questions you might have.
Kind regards,
Julian Benkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I have posted the code below. There is one small glitch. After you type in a filter (the radgridview requires the data with "Select TOP") but due to the requery it takes the focus of the filter text box. Is there a way I can put the focus back to the last filter column with the "blinking text cursor" to the right of the text. (Not selecting the filter text) .
Thank you,
Goran Djuric
Imports Telerik.WinControls
Imports Telerik.WinControls.UI
Imports Telerik.WinControls.Docking
''' <summary>
''' PROPERTY SEARCH FORM
''' </summary>
Public Class frmPropertySearch
Inherits ShapedForm
Private formLoading As Boolean = True
Private strFilter As String = ""
#Region " --== FORM PROPERTIES ==-- "
''' <summary>
''' VIEW NAME
''' </summary>
Private strViewName As String
Public Property ViewName() As String
Get
Return strViewName
End Get
Set(ByVal value As String)
strViewName = value
End Set
End Property
#End Region
''' <summary>
''' FORM LOAD
''' </summary>
Private Sub frmPropertySearch_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'-- LOADS THE MAIN COLUMN ITEMS THE (SEARCH DATAGRID)
loadMainDataGrid()
'-- SETTING ALL COLUMNS TO FILTER BY (STARTS WITH)
For i As Integer = 0 To rgvMain.Columns.Count - 1
CType(Me.rgvMain.MasterGridViewTemplate.Columns(i), GridViewDataColumn).Filter.Function = GridKnownFunction.StartsWith
Next
tlpPropertySearch.RowStyles.Remove(tlpPropertySearch.RowStyles.Item(3))
formLoading = False
End Sub
''' <summary>
''' LOADS THE SEARCH DATA
''' </summary>
Private Sub loadMainDataGrid()
rgvMain.Rows.Clear()
'-- VIEW NAME (T-SQL VIEW)
ViewName = "srcProperty"
'-- TOP 500 LOADS IN UNDER 1 SEC :)
Dim strProp As String = "Select top 500 * from " & ViewName & " " & IIf(strFilter <> "", " where ", "") & " " & strFilter
Dim daProp As New OleDb.OleDbDataAdapter(strProp, conNFAD_NEW)
Dim dsProp As New DataSet
daProp.Fill(dsProp, "dtProp")
rgvMain.DataSource = dsProp.Tables("dtProp")
rgvMain.Refresh()
End Sub
''' <summary>
''' SELECTING A PROPERTY
''' </summary>
Private Sub rbeSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbeSelect.Click
'--== PASSING PRIMARY KEY TO PASSING OBJECT AND OPENING PASSING OBJECT (FORM)
mdiMain.propForm.pkValue = rgvMain.SelectedRows.Item(0).Cells(0).Value
mdiMain.propForm.MdiParent = mdiMain
mdiMain.propForm.Dock = DockStyle.Fill
mdiMain.propForm.Show()
mdiMain.propForm.loadData()
mdiMain.propForm.Visible = True
Me.Close()
'mdiMain.popup = passingObject
End Sub
''' <summary>
''' RAD GRID VIEW - FILTER CHANGED EVENT
''' </summary>
Private Sub rgvmain_filterchanged(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.FilterChangedEventArgs) Handles rgvMain.FilterChanged
If formLoading = True Then Exit Sub
strFilter = "" '--> PRIVATE FILTER STRING (CLEAR EVERY TIME FILTER EVENT RUNS)
For i As Integer = 0 To rgvMain.Columns.Count - 1 '--> LOOPING THORUGH RAD GRID VIEW COLUMNS
If CType(Me.rgvMain.MasterGridViewTemplate.Columns(i), GridViewDataColumn).Filter.StringValue <> vbNullString Then '--> IF THE FILTER STRING IN A GIVEN COLUMN IS NOT NULL
If strFilter <> "" Then strFilter += " and " '--> IF THE strFILTER IS NOT "" THEN IT ALREADY HAS A FILTER SO ADD (and) BEFORE ADDING NEXT FILTER
strFilter += Me.rgvMain.Columns(i).HeaderText '--> ADDING COLUMN NAME
strFilter += " like '"
strFilter += CType(Me.rgvMain.MasterGridViewTemplate.Columns(i), GridViewDataColumn).Filter.StringValue '--> ADDING FILTER VALUE
strFilter += "%'"
End If
Next
'-- CALLING THE DATAGRID LOAD EVENT (TO REQUERY DATA)
loadMainDataGrid()
End Sub
End Class
Thank you for writing.
Currently, the filtering row cannot be focused through the API. We will consider adding this feature in one of our future releases. Do not hesitate to write us if you have other questions.
Kind regards,
Jack
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I have found myself able to do the following:
private void TransactionList_Activated(object sender, EventArgs e) |
{ |
this.radGridView1.MasterGridViewInfo.TableFilteringRow.IsCurrent = true; |
} |
This does successfully, upon the WinForm receiving focus, set the focus into the Filtering Row of the gridview. That said, I only have 1 column in the grid, and it goes nicely to that column for text entry, but I'm not sure what would happen on a multi-column grid.
My only issue now is, this grid is a single integer-based column grid. When the window pops up and I begin typing, the first keypress triggers a form KeyPress event that has a sender type of Telerik.WinControls.UI.RadGridView, and places the digit typed at the beginning of the filter textbox; however, it then places the cursor BEFORE that character. Subsequent keypresses do not trigger a form KeyPress event. I'm not sure if there is an event I can use to hook into future keypresses or not.
Basically, I wanted to point out that now, there IS a way to give focus to the TableFilteringRow, and ask if there is a way, when doing this, to have two subsequent keypresses place the inputted characters in the proper order.
You can use the following code to focus a cell in the filtering row:
protected
override
void
OnActivated(EventArgs e)
{
base
.OnActivated(e);
this
.radGridView1.MasterGridViewInfo.TableFilteringRow.IsCurrent =
true
;
this
.radGridView1.Columns[1].IsCurrent =
true
;
this
.radGridView1.BeginEdit();
}
If you continue to experience the issue, please send us your project so we can test and locate the problem. I will be glad to help you further.
Sincerely yours,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Usually for unrelated questions you should open a new thread, so people could easily find the right answer for your question.
grid.MasterView.SystemRows.Move(grid.MasterView.SystemRows.IndexOf(grid.MasterView.TableAddNewRow), grid.MasterView.SystemRows.IndexOf(grid.MasterView.TableFilteringRow));
This should solve your problem.
Best Regards,
Emanuel Varga
Winforms MVP
this problem is with gridview/50000 rows.
i hope u got my point.
The error you are getting is just extra code you have copied from the example, concerning the demo application. You should not need it and you can safely remove it. Here you can get acquainted with the RadGridView control data binding: http://www.telerik.com/help/winforms/gridview-populating-with-data-tutorial-binding-to-datatable-or-dataset.html.
Regards,
George
Telerik