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

[Solved] client-side load not displaying items

2 Answers 135 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Joel Brom
Top achievements
Rank 1
Joel Brom asked on 19 Feb 2010, 06:39 PM
Using your example for Performance with Web Services.  My app returns 8000+ items from the service and loads in < 10 seconds.  Yet the RCB appears empty after loading.  What am I mssing?

    function RequestingLoadofCombo(sender, eventArgs)  
    {  
        eventArgs.get_context()["DivID"] = RowDivID;  
        eventArgs.get_context()["Type"] = ContactType;  
    }  
    function Loaded()  
    {  
        alert("Loaded");  
    }  
 
 
                <telerik:RadComboBox ID="NonMembersComboBox" runat="server"   
                         Height="100px" Width="220px" ShowMoreResultsBox="true" MarkFirstMatch="true" 
                         EnableLoadOnDemand="True" OnClientItemsRequesting="RequestingLoadofCombo" 
                         OnClientItemsRequested="Loaded">  
                <WebServiceSettings Method="LoadCombo" Path="Admin.aspx" /> 
                 </telerik:RadComboBox> 
 
public class ComboBoxItemData  
{  
    private string text;  
 
        public string Text  
        {  
            get { return text; }  
            set { text = value; }  
        }  
    }  
 
    public static RadComboBoxData LoadCombo(RadComboBoxContext context)  
    {  
        int divID = (int)(context["DivID"]);  
        string typeString = (string)(context["Type"]);  
        char type = Convert.ToChar(typeString);  
        RadComboBoxData result = new RadComboBoxData();  
        List<RadComboBoxItemData> items = new List<RadComboBoxItemData>();  
        List<string> list = new List<string>();  
        Contacts c = new Contacts();  
        list = c.GetNonContacts(divID, type);  
        foreach (string id in list)  
        {  
            RadComboBoxItemData itemData = new RadComboBoxItemData();  
            itemData.Text = id;  
            items.Add(itemData);  
        }  
 
        result.Items = items.ToArray();  
        result.EndOfItems = true;  
 
        return result;  
    }  
 
 
 
 
 

2 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 25 Feb 2010, 04:42 PM
Hi Joel Brom,

The code snippets that you sent to us give just a partial representation of the issue, so I had to guess how your code works and what the issue itself can be.

I made for you a small example to illustrate the approach that resolves the issue - naturally you can extend it to fit it in your application.

Note: The web method that you call seems to use a custom library that I don't have here, so I simulated 8000 Items and made a loop to make the method return them in portions. As I don't know what are RowDivID and ContactType variables I just passed them to the context.

<script type="text/javascript" language="javascript">
    var RowDivID = 1;
    var ContactType = 1;
    function RequestingLoadofCombo(sender, eventArgs) {
 
        var context = eventArgs.get_context();
        context["DivID"] = RowDivID;
        context["Type"] = ContactType;
    }
</script>

<telerik:RadComboBox ID="NonMembersComboBox" runat="server" Height="100px" Width="220px"
    ShowMoreResultsBox="true" MarkFirstMatch="true" EnableLoadOnDemand="True"
    OnClientItemsRequesting="RequestingLoadofCombo">
    <WebServiceSettings Path="LoadItemsWebService.asmx" Method="GetCompanyNames" />
</telerik:RadComboBox>

private const int ItemsPerRequest = 10;
[WebMethod]
public  RadComboBoxData GetCompanyNames(RadComboBoxContext context)
{
    int dataRowsCount = 8000;
    RadComboBoxData comboData = new RadComboBoxData();
    int itemOffset = context.NumberOfItems;
    int endOffset = Math.Min(itemOffset + ItemsPerRequest, dataRowsCount);
    comboData.EndOfItems = endOffset == dataRowsCount;
 
    List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(endOffset - itemOffset);
 
    for (int i = itemOffset; i < endOffset; i++)
    {
        RadComboBoxItemData itemData = new RadComboBoxItemData();
        itemData.Text = "itemNo"+i.ToString();
        itemData.Value = i.ToString();
 
        result.Add(itemData);
    }
    comboData.Items = result.ToArray();
    return comboData;
}

If the issue persists, could you send us sample runnable code, which does not use custom libraries or databases?

Thank you in advance.

Greetings,
Kalina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Joel Brom
Top achievements
Rank 1
answered on 25 Feb 2010, 05:52 PM
Thank you for the example.  I have redesigned my application to use an AJAX autocomplete extender which worked out to be a better solution.
Tags
ComboBox
Asked by
Joel Brom
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Joel Brom
Top achievements
Rank 1
Share this question
or