This is a migrated thread and some comments may be shown as answers.

[Solved] LoadOnDemand doesn't show any entries

5 Answers 120 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Torben
Top achievements
Rank 1
Torben asked on 20 Aug 2009, 02:01 PM
Hi,

I'm trying to implement a combobox which should dynamically load and display some data from a xml-file.
In debugger I can see that the data is loaded correctly and is added to the combobox-control via RadComboBox1.Items.Add(...).

But afterwards nothing is displayed in the combobox - the box still remains displaying "Loading..."

The Data I'm expecting is:
"", ""                   (empty Strings)
"data1", "data1"
"data2", "data2"
"data3", "data3"
"data4", "data4"

Here's the code of the combobox-control in my .aspx-file:
<telerik:RadComboBox ID="RadComboBox1" runat="server" AllowCustomText="True" EmptyMessage="Choose Data" EnableLoadOnDemand="True" ShowMoreResultsBox="true" 
EnableVirtualScrolling="true" Filter="StartsWith" AutoPostBack="True" DataTextField="Name" DataValueField="Name"
</telerik:RadComboBox> 

Here is what is done on the server in my .aspx.vb-file:
Protected Sub RadComboBox1_ItemsRequested(ByVal sender As ObjectByVal e As RadComboBoxItemsRequestedEventArgs) Handles RadComboBox1.ItemsRequested 
        Dim data As DataTable = GetData(e.Text) 
 
        Dim itemOffset As Integer = e.NumberOfItems 
        Dim endOffset As Integer = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count) 
        e.EndOfItems = endOffset = data.Rows.Count 
 
        For i As Integer = 0 To data.Rows.Count - 1 
            RadComboBox1.Items.Add(New RadComboBoxItem(data.Rows(i)("Name").ToString(), data.Rows(i)("Name").ToString())) 
        Next 
 
        e.Message = GetStatusMessage(endOffset, data.Rows.Count) 
    End Sub 

Does somebody has an idea or hint on what I'm doing wrong?

Kind regards,
Torben

5 Answers, 1 is accepted

Sort by
0
Torben
Top achievements
Rank 1
answered on 20 Aug 2009, 05:57 PM
May be a problem with the master-layout?
When I use an example without master-page all works fine - when I use a master-page it won't work any more....

Any ideas on this?
0
Yana
Telerik team
answered on 21 Aug 2009, 02:39 PM
Hello Torben,

The provided information is not enough for us to reproduce the problem.  Could you please paste here a simpler version of  your page and master page so we could replicate the issue? Thanks

Best wishes,
Yana
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
Torben
Top achievements
Rank 1
answered on 21 Aug 2009, 08:08 PM
Hi Yana,

I think I figured it out.
I had to ensure that there is no other Content-Output before "RadAjaxPanel". Before, I wether not used "RadAjaxPanel" or it has been included after something was output.

This won't work for me:
<%@ Master Language="VB" CodeFile="default_ajax.master.vb"  Inherits="ajax_internal_MasterPage"%> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<body>  
    <form id="form1" runat="server">  
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />  
              
        <div class="menu">  
            My Main-Menu-Content  
        </div>  
          
        <div style="margin:2px; margin-top:5px; vertical-align:top;"
          <!-- content start -->  
          <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1">   
                <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">  
                </asp:contentplaceholder> 
          </telerik:RadAjaxPanel> 
          <!-- content end --> 
        </div>  
 
    </form>  
</body>  


So my MasterPage has to look something like this to work correctly for me:
<%@ Master Language="VB" CodeFile="default_ajax.master.vb"  Inherits="ajax_internal_MasterPage"%>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
body> 
    <form id="form1" runat="server"
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
    <!-- content start --> 
    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1"
         
        <div class="menu"
            My Main-Menu-Content 
        </div> 
         
        <div style="margin:2px; margin-top:5px; vertical-align:top;"
                <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"
                </asp:contentplaceholder> 
        </div> 
     
    </telerik:RadAjaxPanel> 
    <!-- content end --> 
    </form> 
</body>


Torben
0
Yana
Telerik team
answered on 24 Aug 2009, 01:20 PM
Hi Torben,

This is strange, RadAjax panel should work even if there's output content before it, but you shouldn't use Loan-On-Demand mechanism of RadComboBox along with RadAjax, you should entirely use the combobox in a server mode - adding the items in the Load event of the page for instance. The AJAX Panel will take care of transforming the postback into a callback and thus keeping the needed client-side experience. 

Best wishes,
Yana
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
Torben
Top achievements
Rank 1
answered on 27 Aug 2009, 07:28 AM
Hi Yana,

at the moment I'm doing some other projects and will come back to this "problem" in about 4-6 days.
I'll try it out and give you some feedback. Thx for your assistance.

Kind regards,
Torben
Tags
ComboBox
Asked by
Torben
Top achievements
Rank 1
Answers by
Torben
Top achievements
Rank 1
Yana
Telerik team
Share this question
or