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

[Solved] Issue with RadComboBox Q3 2009

1 Answer 73 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Raj
Top achievements
Rank 1
Raj asked on 22 Dec 2009, 10:25 AM
Hello,
I am using Telerik Contorl Q3 2009 version 2009.03.1103.20.
I am getting problmes while loading Rad combobox on item requested event.
Though i have written code for Items.clear() it is not working.
When i debug the application it shows Items.count to 0 but in UI it is not clearing that. You can see the attached screenshot

Also code which i had written
ASPX code

 

<telerik:RadComboBox Skin="Default" EnableVirtualScrolling="false" EnableEmbeddedSkins="true" ID="RadComboBox_Test"

 

 

runat="server" EnableLoadOnDemand="true" Height="300px" DropDownWidth="800px"

 

 

Width="400px" ItemRequestTimeout="500" HighlightTemplatedItems="true" AutoPostBack="true"

 

 

ShowToggleImage="false" onitemsrequested="RadComboBox_Test_ItemsRequested">

 

 

<ItemTemplate>

 

 

<table style="width: 800px; text-align: left;">

 

 

<tr>

 

 

<td style="width: 300px;" align="left">

 

<%

# DataBinder.Eval(Container.DataItem, "author")%>

 

 

</td>

 

 

<td style="width: 300px;" align="left">

 

<%

# DataBinder.Eval(Container.DataItem, "title")%>

 

 

</td>

 

 

<td style="width: 200px;" align="left">

 

<%

# DataBinder.Eval(Container.DataItem, "price")%>

 

 

</td>

 

 

</tr>

 

 

</table>

 

 

</ItemTemplate>

 

 

<HeaderTemplate>

 

 

<table style="width: 800px; text-align: left;">

 

 

<tr>

 

 

<td style="width: 300px;" align="left">

 

Author

 

</td>

 

 

<td style="width: 300px;" align="left">

 

Title

 

</td>

 

 

<td style="width: 200px;" align="left">

 

Price

 

</td>

 

 

</tr>

 

 

</table>

 

 

</HeaderTemplate>

 

 

</telerik:RadComboBox>

 


ASPX.CS file code

 

protected void RadComboBox_Test_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)

 

{

 

try

 

{

 

string contactName = e.Text;

 

 

if (contactName.Length < 3)

 

 

return;

 

 

DataSet dataSet = new DataSet();

 

dataSet.ReadXml(Server.MapPath(

"~/TestXML2.xml"));

 

RadComboBox_Test.Items.Clear();

 

if (dataSet != null)

 

{

 

if (dataSet.Tables.Count > 0)

 

{

DataView dv = new DataView();

 

 

if (dataSet.Tables[0].Rows.Count == 0)

 

{

 

DataRow dataRow = dataSet.Tables[0].NewRow();

 

dataRow[

"author"] = "No Contacts found";

 

dataRow[

"title"] = "No Contacts found";

 

dataRow[

"price"] = "No Contacts found";

 

dataSet.Tables[0].Rows.Add(dataRow);

dv =

new DataView(dataSet.Tables[0]);

 

}

 

else

 

{

dv =

new DataView(dataSet.Tables[0]);

 

dv.Sort =

"author, title ASC";

 

dv.RowFilter =

"author like '" + contactName + "%'";

 

}

RadComboBox_Test.DataValueField =

"id";

 

RadComboBox_Test.DataTextField =

"title";

 

RadComboBox_Test.ClearSelection();

RadComboBox_Test.Items.Clear();

RadComboBox_Test.DataSource = dv;

RadComboBox_Test.DataBind();

}

}

}

 

catch (Exception ex)

 

{

Response.Write(ex.ToString());

}

}



I am using script manager in master page and updatepanel in aspx page.

Please help me ASAP.

Regards

Raj

1 Answer, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 23 Dec 2009, 01:11 PM
Hi Raj,

This happens because you have enabled Virtual Scrolling. In this case, each new Item added via the ItemsRequested event handler when scrolling the drop down will be appended to the already loaded Items even if you call Items.Clear in the event handler.

You could avoid this by setting EnableVirtualScrolling to false. Please see this demo for more information about the Load On Demand behavior of RadComboBox.

Greetings,
Simon
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.
Tags
ComboBox
Asked by
Raj
Top achievements
Rank 1
Answers by
Simon
Telerik team
Share this question
or