My "load on demand" is extremely slow. There are about 250,000 records in the table but I understood that even with this number of records the load-on-demand should have acceptable performance. Please take a look at the code here and let me know if there's a setting somewhere which I'm missing. When I click in the combobox it says "loading..." for minutes before anything shows up in the list. Thanks.
ASPX:
<telerik:RadComboBox ID="rcbProductCode" runat="server" Width="250px" Height="200px"
AllowCustomText="True" ShowToggleImage="True" ShowMoreResultsBox="true"
EnableLoadOnDemand="True" MarkFirstMatch="True"
OnItemsRequested="rcbProductCode_ItemsRequested" EnableVirtualScrolling="true" >
</telerik:RadComboBox>
VB.NET:
Protected Sub rcbProductCode_ItemsRequested(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs)
Dim sql As String = _
"SELECT PRODUCT = RTRIM(PRODUCT_CODE) + ' - ' + RTRIM(PRODUCT_DESC), PRODUCT_CODE " & _
"FROM AllianceSync.DBO.FDA_PRODUCT (NOLOCK) " & _
"WHERE PRODUCT_CODE like '" + e.Text + "%'"
Dim connTmp As New SqlConnection(strConnString)
connTmp.Open()
Dim adapter As New SqlDataAdapter(sql, connTmp)
Dim data As New DataTable()
adapter.Fill(data)
Dim rcb As Telerik.Web.UI.RadComboBox = CType(o, Telerik.Web.UI.RadComboBox)
Try
Dim itemsPerRequest As Integer = 10
Dim itemOffset As Integer = e.NumberOfItems
Dim endOffset As Integer = itemOffset + itemsPerRequest
If endOffset > data.Rows.Count Then
endOffset = data.Rows.Count
End If
If endOffset = data.Rows.Count Then
e.EndOfItems = True
End If
Dim i As Integer = itemOffset
While i < endOffset
rcb.Items.Add(New Telerik.Web.UI.RadComboBoxItem(data.Rows(i)("PRODUCT").ToString(), data.Rows(i)("PRODUCT_CODE").ToString()))
i = i + 1
End While
If data.Rows.Count > 0 Then
e.Message = [String].Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString())
Else
e.Message = "No matches"
End If
Catch
e.Message = "No matches"
End Try
I've seen other posts where people are having similar issues. I tried their suggestions and still no good. I cannot get this grid to fire the update command. I'm programmatically creating the grid and using a template edit form...
| private void SetupStoreGridView() |
| { |
| // create columns |
| GridEditCommandColumn storeEditCol = new GridEditCommandColumn(); |
| GridBoundColumn storeNumberCol = new GridBoundColumn(); |
| GridBoundColumn storeNameCol = new GridBoundColumn(); |
| GridBoundColumn storePhoneCol = new GridBoundColumn(); |
| GridBoundColumn storeAddressCol = new GridBoundColumn(); |
| GridBoundColumn storeCityCol = new GridBoundColumn(); |
| GridBoundColumn storeStateCol = new GridBoundColumn(); |
| GridBoundColumn storeZipCol = new GridBoundColumn(); |
| GridBoundColumn storeDesignNameCol = new GridBoundColumn(); |
| GridBoundColumn storeChocolixirCol = new GridBoundColumn(); |
| // main grid properties |
| m_StoreGridViewRad = new RadGrid(); |
| m_StoreGridViewRad.ID = "StoreGridViewRad"; |
| m_StoreGridViewRad.GridLines = GridLines.Vertical; |
| m_StoreGridViewRad.AllowMultiRowSelection = false; |
| m_StoreGridViewRad.AutoGenerateColumns = false; |
| m_StoreGridViewRad.AllowSorting = true; |
| m_StoreGridViewRad.Skin = "WebBlue"; |
| m_StoreGridViewRad.Width = Unit.Percentage(95); |
| m_StoreGridViewRad.UpdateCommand += new GridCommandEventHandler(m_StoreGridViewRad_UpdateCommand); |
| m_StoreGridViewRad.MasterTableView.AllowAutomaticUpdates = true; |
| m_StoreGridViewRad.MasterTableView.EditFormSettings.EditFormType = GridEditFormType.Template; |
| m_StoreGridViewRad.MasterTableView.EditFormSettings.FormTemplate = new EditStoreTemplate(); |
| m_StoreGridViewRad.NeedDataSource += new GridNeedDataSourceEventHandler(StoreGridViewRad_NeedDataSource); |
| m_StoreGridViewRad.AllowFilteringByColumn = true; |
| m_StoreGridViewRad.MasterTableView.DataKeyNames = new string[] { StoreAccess.StoreNumber }; |
| m_StoreGridViewRad.MasterTableView.EnableNoRecordsTemplate = true; |
| // add columns to grid |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeEditCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeNumberCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeNameCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storePhoneCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeAddressCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeCityCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeStateCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeZipCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeDesignNameCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeChocolixirCol); |
| SetupGridViewColumn(storeNumberCol, StoreAccess.StoreNumber, "Store Number"); |
| SetupGridViewColumn(storeNameCol, StoreAccess.StoreName, StoreAccess.StoreName); |
| SetupGridViewColumn(storePhoneCol, StoreAccess.Phone, StoreAccess.Phone); |
| SetupGridViewColumn(storeAddressCol, StoreAccess.Address, StoreAccess.Address); |
| SetupGridViewColumn(storeCityCol, StoreAccess.City, StoreAccess.City); |
| SetupGridViewColumn(storeStateCol, StoreAccess.State, StoreAccess.State); |
| SetupGridViewColumn(storeZipCol, StoreAccess.Zip, StoreAccess.Zip); |
| SetupGridViewColumn(storeDesignNameCol, StoreAccess.DesignName, "Design Name"); |
| SetupGridViewColumn(storeChocolixirCol, StoreAccess.Chocolixir, StoreAccess.Chocolixir); |
| GridViewPlaceHolder.Controls.Add(m_StoreGridViewRad); |
| } |
| void m_StoreGridViewRad_UpdateCommand(object source, GridCommandEventArgs e) |
| { |
| GridEditableItem ei = ((GridEditableItem)(e.Item)); |
| Hashtable t1 = new Hashtable(); |
| ei.ExtractValues(t1); |
| string s = t1[StoreAccess.StoreName].ToString(); |
| } |
| protected void StoreGridViewRad_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
| { |
| GetStoresToBind(); |
| } |
| void SetupGridViewColumn(GridColumn col, string uniqueName, string heading) |
| { |
| col.HeaderText = heading; |
| col.UniqueName = uniqueName; |
| col.ItemStyle.HorizontalAlign = HorizontalAlign.Left; |
| if (col is GridBoundColumn) |
| { |
| GridBoundColumn bCol = col as GridBoundColumn; |
| bCol.DataField = uniqueName; |
| } |
| else if (col is GridButtonColumn) |
| { |
| GridButtonColumn buttonCol = col as GridButtonColumn; |
| buttonCol.CommandName = uniqueName; |
| buttonCol.Text = uniqueName; |
| } |
| } |
| public class EditStoreTemplate : IBindableTemplate |
| { |
| public EditStoreTemplate() |
| { |
| } |
| #region ITemplate Members |
| public void InstantiateIn(Control container) |
| { |
| GridEditFormItem item = ((GridEditFormItem)(container.NamingContainer)); |
| if (item != null) |
| { |
| int index = ((GridDataItem)item.ParentItem).ItemIndex; |
| if (item.DataItem != null) |
| { |
| RadTextBox storeNumberTB = new RadTextBox() |
| { |
| ID = "txtStorNumber", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.StoreNumber, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(storeNumberTB); |
| RadTextBox storeNameTB = new RadTextBox() |
| { |
| ID = "txtStoreName", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.StoreName, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(storeNameTB); |
| RadTextBox addrTB = new RadTextBox() |
| { |
| ID = "txtAddr", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.Address, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(addrTB); |
| RadTextBox cityTB = new RadTextBox() |
| { |
| ID = "txtCity", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.City, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(cityTB); |
| RadTextBox stateTB = new RadTextBox() |
| { |
| ID = "txtState", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.State, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(stateTB); |
| RadTextBox zipTB = new RadTextBox() |
| { |
| ID = "txtZip", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.Zip, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(zipTB); |
| RadMaskedTextBox phoneTB = new RadMaskedTextBox() |
| { |
| ID = "txtPhone", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.Phone, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(phoneTB); |
| RadTextBox notesTB = new RadTextBox() |
| { |
| ID = "txtNotes", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.Notes, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(notesTB); |
| RadComboBox designNameCombo = new RadComboBox() |
| { |
| ID = "cboDesignName", |
| DataSource = DesignAccess.GetDesign(), |
| DataTextField = DesignAccess.DesignName, |
| DataValueField = DesignAccess.DesignNumber, |
| SelectedValue = DataBinder.Eval(item.DataItem, StoreAccess.DesignNumber, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(designNameCombo); |
| RadTextBox regionTb = new RadTextBox() |
| { |
| ID= "txtRegion", |
| Text = DataBinder.Eval(item.DataItem,StoreAccess.Reg,"{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(regionTb); |
| RadTextBox typeTB = new RadTextBox() |
| { |
| ID = "txtType", |
| Text= DataBinder.Eval(item.DataItem,StoreAccess.Type,"{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(typeTB); |
| CheckBox chocolixirCB = new CheckBox() |
| { |
| ID = "chkChocolixir", |
| Checked = bool.Parse(DataBinder.Eval(item.DataItem, StoreAccess.Chocolixir, "{0}")), |
| Text = StoreAccess.Chocolixir, |
| CausesValidation = false |
| }; |
| container.Controls.Add(chocolixirCB); |
| CheckBox gCB = new CheckBox() |
| { |
| ID = "chkG", |
| Checked = bool.Parse(DataBinder.Eval(item.DataItem, StoreAccess.G, "{0}")), |
| Text = "G", |
| CausesValidation = false |
| }; |
| container.Controls.Add(gCB); |
| Button updateButton = new Button() |
| { |
| ID = "updateButton", |
| Text = "Update", |
| CommandName = "Update", |
| CausesValidation = false |
| }; |
| container.Controls.Add(updateButton); |
| Button cancelButton = new Button() |
| { |
| ID = "cancelButton", |
| Text = "Cancel", |
| CausesValidation = false |
| }; |
| cancelButton.Click += new EventHandler(cancelButton_Click); |
| container.Controls.Add(cancelButton); |
| } |
| } |
| } |
| void cancelButton_Click(object sender, EventArgs e) |
| { |
| } |
| #endregion |
| #region IBindableTemplate Members |
| public System.Collections.Specialized.IOrderedDictionary ExtractValues(Control container) |
| { |
| OrderedDictionary od = new OrderedDictionary(); |
| od.Add(StoreAccess.StoreName,(container.FindControl("txtStoreName") as RadTextBox).Text); |
| return od; |
| } |
| #endregion |
| } |
$create(Telerik.Web.UI.RadTreeView, {"_postBackDEFANGED_OnClick":true,"_postBackOnContextMenuItemClick":true,"_postBackReference":"__doPostBack(\u0027ctl00$filas$dckFilas$C$tevFilasPublicas\u0027,\u0027arguments\u0027)","_scrollPosition":0,"_skin":"Default","_uniqueId":"ctl00$filas$dckFilas$C$tevFilasPublicas","clientStateFieldID":"ctl00_filas_dckFilas_C_tevFilasPublicas_ClientState","collapseAnimation":"{\"type\":12,\"duration\":100}","contextMenuIDs":["MainContextMenu"],"expandAnimation":"{\"duration\":100}","nodeData":[{"value":"1"},{"value":"2"},{"value":"3"},{"value":"4"},{"value":"5"},{"value":"6"},{"value":"7","selected":1},{"value":"8"},{"value":"9"},{"value":"10"}],"selectedIndexes":["6"]}, null, null, $get("ctl00_filas_dckFilas_C_tevFilasPublicas"));
| <telerik:RadToolbar ID="RadToolbar1" runat="server" |
| Style="clear: both; width: 100%;" AutoPostBack="True" |
| ononclick="RadToolbar1_OnClick" onbuttonclick="RadToolbar1_ButtonClick" |
| Skin="Web20" > |
| <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
| <Items> |
| <telerik:RadToolbarButton runat="server" ButtonImage="new.gif" |
| ButtonText="New Artist" Hidden="False" ID="RadToolbarButton1" |
| ToolTip="New Artist" CommandName="newartist" DisplayType="TextImage" |
| CausesValidation="False" Font-Bold="True" ForeColor="Black" |
| ImageUrl="~/Img/addNewItem.gif" NavigateUrl="AddArtist.aspx" Text="New Artist"/> |
| <telerik:RadToolBarButton runat="server" CommandName="bandmembers" ToolTip="Band Members" |
| ButtonImage="People.gif" ButtonText="Band Members" Hidden="False" |
| DisplayType="TextImage" Font-Bold="True" ForeColor="Black" |
| ImageUrl="~/Img/People.gif" Text="Band Members"></telerik:RadToolBarButton> |
| <telerik:RadToolBarButton runat="server" CommandName="artistmedia" ToolTip="Artist Media" |
| ButtonImage="otherMedia.gif" ButtonText="Artist Media" Hidden="False" |
| DisplayType="TextImage" Font-Bold="True" ForeColor="Black" |
| ImageUrl="~/Img/Web4_ico_4.gif" Text="Media"></telerik:RadToolBarButton> |
| </Items> |
| <Items> |
| <telerik:RadToolbarButton runat="server" ButtonImage="People.gif" ButtonText="Band Members" Hidden="False" ID="RadToolbarButton3" ToolTip="Band Members" CommandName="bandmembers" DisplayType="TextImage"/> |
| </Items> |
| <Items> |
| <telerik:RadToolbarButton runat="server" ButtonImage="otherMedia.gif" ButtonText="Artist Media" Hidden="False" ID="RadToolbarButton2" ToolTip="Artist Media" CommandName="artistmedia" DisplayType="TextImage"/> |
| </Items> |
| </telerik:RadToolbar> |