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

[Solved] RadCombo box clearing Items

3 Answers 153 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Srinath
Top achievements
Rank 1
Srinath asked on 19 May 2009, 12:54 PM
Hi Team,

Assume cmbSectionTitle  is my RadComboBox. I need to do the following operations in JavaScript or with page post back.

 

cmbSectionTitle.DataSource =

null;

 

cmbSectionTitle.Text =

string.Empty;

 



Could you please help me out....

Thanks,
--Srinath

3 Answers, 1 is accepted

Sort by
0
Saed
Top achievements
Rank 1
answered on 19 May 2009, 09:46 PM
Hi there,

Apparently you are trying to clear your combo from items as we as clearing text from InputArea... I've done something similar (JavaScript) like this:

        function pageLoad() { 
            myCombo = $find("<%= rcb_TargetCombo.ClientID %>"); 
            myCombo.clearSelection();   // Reset InputArea, selectedItem, selectedIndex, etc... to null 
            myCombo.clearItems();       // Remove all combo items 
        } 


Hope this helps.

Regards,
Saed

0
Srinath
Top achievements
Rank 1
answered on 20 May 2009, 12:52 PM

Thanks for your previous post.

Sample Code: ascx
--------------------------

 

<

 

telerik:RadCodeBlock ID="rdAuthor" runat="server">

 

 

 

<div class="catalog">

 

 

 

    <telerik:RadAjaxPanel ID="upnlAuthor" EnableHistory="true" EnableViewState="true" runat="server"     LoadingPanelID="LoadingPanel2"

 

 

EnableOutsideScripts="true" EnableAJAX="true" >

 

 

 

 

 

<asp:HiddenField ID="hdnTest" runat="server" />

 

 

 


 

 

 

<td class="field" style="width: 105px;">

 

 

 

 

 

 

<asp:DropDownList runat="server" ID="ddlSearchAuthor" Width="100px" AutoPostBack="true" CssClass="selectinput" OnSelectedIndexChanged="ddlSearchAuthor_SelectedIndexChanged" >

 

 

 

 

 

 

<asp:ListItem Text="--Search on--" Value="Search on" ></asp:ListItem>

 

 

 

 

 

 

<asp:ListItem Text="First Name" Value="firstname"></asp:ListItem>

 

 

 

 

 

 

<asp:ListItem Text="Last Name" Value="lastname"></asp:ListItem>

 

 

 

 

 

 

<asp:ListItem Text="Display Name" Value="displayname"></asp:ListItem>

 

 

 

 

 

 

<asp:ListItem Text="Author ID" Value="authorID"></asp:ListItem>

 

 

 

 

 

 

</asp:DropDownList>

 

 

 

 

 

 

</td>

 

 

 

 

 

 

<td class="field" style="width: 310px;">

 

 

 

 

 

 

<telerik:RadComboBox id="cmbSectionTitle"

 

 

EnableLoadOnDemand="True"

 

 

EnableVirtualScrolling="false"

 

 

 

 

 

 

ShowToggleImage="false"

 

 

Runat="server"

 

 

 

 

 

 

Height="140px"

 

 

 

 

 

 

Width="250px"

 

 

 

 

 

 

OnItemsRequested="cmbSectionTitle_ItemsRequested"

 

 

ShowDropDownOnTextboxClick ="false"

 

 

 

 

 

 

CloseDropDownOnBlur = "true"

 

 

 

 

 

 

Filter="StartsWith"

 

 

OnSelectedIndexChanged="cmbSectionTitle_SelectedIndexChanged"

 

 

OnTextChanged="cmbSectionTitle_TextChanged" ShowMoreResultsBox="true" >

 

 

 

 

 

 

</telerik:RadComboBox>

 

 

 

 

</td>

 

 

 






</telerik:RadAjaxPanel >

 

 

</telerik:RadCodeBlock>

 

 

 

==========================================
ascx.cs
=========================================

 

 

protected void cmbSectionTitle_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)

 

{

 

 

 

try

 

 

 

 

{

 

 

 

if (hdnTest.Value != "Search on") /// This is empty always :(

 

{

 

 ///do some thing
}
}

}


The above hdnTest is set to chagned value in dropdown... ddlSearchAuthor in Javascript.
But in CS the value of hdnTest is showing up as EMPTY :(

What could be the reason. Please help me out.

0
Saed
Top achievements
Rank 1
answered on 20 May 2009, 10:22 PM
As far as I know, during ItemsRequested ALL page controls would be invalid, which indicates you could not capture selected value of a combobox for instance--always returns null. Therefore, Client-Side API provides an alternative mechanism to pass such value as a context via OnClientItemsRequesting. I believe Documentation has a thorough details about that, but can't remember where or the link.

Another thing: I noted you are using asp DropDownList. Handling PopoulateOnDemand is perfectly accomplished with RadComboBox. Consequently, utilising context is granted with RadComboBox but not sure about asp DDL. Why are you mixing controls like this? Couldn't you use RadCombos all the way?

Finally, an advice: When composing messages here, your could use Format Code Block button to insert your code, rather than just copy and paste code into message body. Try it and see how handy it is.

Hope this helps.

Regards,
Saed
Tags
ComboBox
Asked by
Srinath
Top achievements
Rank 1
Answers by
Saed
Top achievements
Rank 1
Srinath
Top achievements
Rank 1
Share this question
or