Hi,
I created dynamically a radcombobox (in a usercontrol). When I try to use the LoadOnDemand feature, it fires the itemsrequested event and I see via a watch that the combobox items are changed, but I do not see them chaning on the screen. What am I doing wrong?
Tia,
Tim
I created dynamically a radcombobox (in a usercontrol). When I try to use the LoadOnDemand feature, it fires the itemsrequested event and I see via a watch that the combobox items are changed, but I do not see them chaning on the screen. What am I doing wrong?
Tia,
Tim
3 Answers, 1 is accepted
0
Hello Tia,
What is shown on the screen?
Can you paste here the combo's declaration and the code behind?
Greetings,
Veselin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
What is shown on the screen?
Can you paste here the combo's declaration and the code behind?
Greetings,
Veselin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
T
Top achievements
Rank 1
answered on 16 Apr 2009, 11:59 AM
Hi Vasilev,
The data that is shown is the initial data like in the combobox declaration. When I click the combobox it fires the itemsrequested event, but the old data is shown. It says also "Loading". Here is some code
Combobox declaration
Code behind
Itemtemplate
Thanks,
Tim
The data that is shown is the initial data like in the combobox declaration. When I click the combobox it fires the itemsrequested event, but the old data is shown. It says also "Loading". Here is some code
Combobox declaration
| control.ID = "DynCombo" |
| control.AllowCustomText = True |
| control.EnableLoadOnDemand = True |
| control.EnableVirtualScrolling = True |
| control.ShowMoreResultsBox = True |
| control.HighlightTemplatedItems = True |
| control.MarkFirstMatch = True |
| control.Width = Unit.Pixel(250) |
| control.Height = Unit.Pixel(200) |
| control.DropDownWidth = 300 |
| control.Skin = "Vista" |
| control.AutoPostBack = True |
| control.EnableItemCaching = True |
| control.EmptyMessage = "Geen gegevens gevonden" |
| control.EnableViewState = True |
| control.HeaderTemplate = New RadComboboxHeaderTemplate() |
| control.ItemTemplate = New RadComboboxItemTemplate() |
| AddHandler control.ItemsRequested, AddressOf DynCombo_ItemsRequested |
| Dim dt As DataTable = Nothing |
| dt = FilterData("") |
| Dim item As RadComboBoxItem = Nothing |
| For i As Integer = 0 To dt.Rows.Count - 1 |
| item = New RadComboBoxItem(dt.Rows(i)(0).ToString, dt.Rows(i)(1).ToString) |
| For j As Integer = 0 To item.Attributes.Count |
| item.Attributes.Add("col_" & j, dt.Rows(i)(j + 2).ToString) |
| Next |
| control.Items.Add(item) |
| Next |
Code behind
| Private Sub DynCombo_ItemsRequested(ByVal obj As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) |
| Dim itemsPerRequest As Integer = 20 |
| Dim itemOffset As Integer = e.NumberOfItems |
| Dim endOffset As Integer = itemOffset + itemsPerRequest |
| Dim item As RadComboBoxItem = Nothing |
| Dim radcombobox As RadComboBox = CType(obj, RadComboBox) |
| radcombobox.Items.Clear() |
| Dim text As String = e.Text |
| Try |
| Dim dt As DataTable = Nothing |
| dt = FilterData(text) |
| If endOffset > dt.Rows.Count Then |
| endOffset = dt.Rows.Count |
| End If |
| If endOffset = dt.Rows.Count Then |
| e.EndOfItems = True |
| Else |
| e.EndOfItems = False |
| End If |
| For i As Integer = 0 To endOffset - 1 |
| item = New RadComboBoxItem(dt.Rows(i)(0).ToString, dt.Rows(i)(1).ToString) |
| For j As Integer = 0 To item.Attributes.Count |
| item.Attributes.Add("col_" & j, dt.Rows(i)(j + 2).ToString) |
| Next |
| radcombobox.Items.Add(item) |
| Next |
| If dt.Rows.Count > 0 Then |
| e.Message = String.Format("Item <b>1</b>-<b>{0}</b> van de <b>{1}</b>", endOffset.ToString, dt.Rows.Count.ToString) |
| Else |
| e.Message = "Geen resultaten" |
| End If |
| Catch ex As Exception |
| e.Message = "Geen resultaten" |
| End Try |
| End Sub |
Itemtemplate
| Public Class RadComboboxItemTemplate |
| Implements ITemplate |
| #Region "Constructors" |
| Public Sub New() |
| End Sub |
| #End Region |
| #Region "ITemplate Members" |
| Sub InstantiateIn(ByVal container As Control) Implements System.Web.UI.ITemplate.InstantiateIn |
| Dim item As RadComboBoxItem = CType(container, RadComboBoxItem) |
| Dim table As New HtmlTable |
| Dim row As New HtmlTableRow |
| Dim cell As New HtmlTableCell |
| cell.ID = "colValue" |
| cell.Width = 100 |
| cell.Style.Add("color", "black") |
| cell.InnerText = item.Value |
| row.Controls.Add(cell) |
| cell = New HtmlTableCell |
| cell.ID = "colText" |
| cell.Width = 100 |
| cell.InnerText = item.Text |
| cell.Style.Add("color", "black") |
| row.Controls.Add(cell) |
| For i As Integer = 0 To item.Attributes.Count - 1 |
| cell = New HtmlTableCell |
| cell.ID = "col_" & i |
| cell.Width = 100 |
| cell.InnerText = item.Attributes("col_" & i).ToString |
| row.Controls.Add(cell) |
| Next |
| table.Rows.Add(row) |
| item.Controls.Add(table) |
| End Sub |
| #End Region |
| End Class |
| Public Class RadComboboxHeaderTemplate |
| Implements ITemplate |
| #Region "ITemplate Members" |
| Sub InstantiateIn(ByVal container As Control) Implements System.Web.UI.ITemplate.InstantiateIn |
| Dim table As New HtmlTable |
| container.Controls.Add(table) |
| Dim row As New HtmlTableRow |
| table.Controls.Add(row) |
| Dim cell As New HtmlTableCell |
| cell.InnerText = "ID" |
| cell.Width = 100 |
| row.Controls.Add(cell) |
| cell = New HtmlTableCell |
| cell.InnerText = "Type" |
| cell.Width = 100 |
| row.Controls.Add(cell) |
| cell = New HtmlTableCell |
| cell.InnerText = "Omschrijving" |
| cell.Width = 100 |
| row.Controls.Add(cell) |
| End Sub |
| #End Region |
| End Class |
Thanks,
Tim
0
T
Top achievements
Rank 1
answered on 20 Apr 2009, 07:09 AM
Ok, i found my problem. I had a "response.write" in my code. If i removed that, my problem was solved.