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

Clearing a radcombo box

5 Answers 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Minh
Top achievements
Rank 1
Minh asked on 07 Sep 2011, 11:35 PM
hi,

I was trying to clear a radcombobox's selected value and text inside a radgrid using RadCombo.ClearSelection() and it failed. please let me know of any simple way to clear the RadCombo on the clientside.

Thanks,
Minh Bui

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Sep 2011, 05:40 AM
Hello Minh,

You can clear the RadComboBox on OnRowClick event.Try setting the following markup and Javascript.
aspx:
<telerik:RadGrid ID="RadGrid1" runat="server">
   <ClientSettings>
      <ClientEvents OnRowClick="OnRowClick" />
   </ClientSettings>
</telerik:RadGrid>
JS:
<script type="text/javascript">
function OnRowClick(sender, args)
 {
   var combo = args.get_gridDataItem().findControl("RadComboBox1");
   combo.clearSelection();
 }
</script>

Thanks,
Shinu.
0
Minh
Top achievements
Rank 1
answered on 08 Sep 2011, 02:20 PM
Hi,

I've made the code change to use the radcombobox's OnClientFocus event....although I'm getting Microsoft JScript runtime error: Object doesn't support this property or method

My objective is to clear the Radcombobox's selection......upon focus - so that the itemrequest will run on the server side and return a full drop down list.

<

script language="javascript" type="text/javascript">  

 

function Area_OnClientFocus(sender, args)  

{var combo = args.get_gridDataItem().findControl("RadComboBoxArea");  

combo.clearSelect();

}

</

script

<telerik:GridTemplateColumn UniqueName="AreaName" HeaderText="Area"  

SortExpression="AreaName" ItemStyle-Width="150px" DataField="_AreaName"  

AndCurrentFilterFunction="Contains">  

<FooterTemplate>  

Template footer

</FooterTemplate

<FooterStyle VerticalAlign="Middle" HorizontalAlign="Center" />  

<ItemTemplate>  

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

</ItemTemplate>  

<EditItemTemplate>  

<telerik:RadComboBox runat="server" ID="RadComboBoxArea"  

EnableLoadOnDemand="True" DataTextField="AreaName"  

OnItemsRequested="RadComboBoxArea_ItemsRequested" DataValueField="ID" AutoPostBack="true"  

HighlightTemplatedItems="true" Height="140px" Width="100px" DropDownWidth="200px"  

OnSelectedIndexChanged="ComboBox1_OnSelectedIndexChangedHandler"  

onclientfocus="Area_OnClientFocus">  

<ItemTemplate> 

<%# DataBinder.Eval(Container, "Text")%> 

</ItemTemplate>  

</telerik:RadComboBox

</EditItemTemplate>  

<HeaderStyle Width="150px" />  

<ItemStyle Width="150px"></ItemStyle>  

</telerik:GridTemplateColumn

 

 

0
Helen
Telerik team
answered on 09 Sep 2011, 02:44 PM
Hello Minh,

You should use the:

combo.clearSelection();

instead of:

combo.clearSelect();

If it doesn't help, could you please open a support ticket and send is a sample project which demonstrates the issue to examine it locally?

Regards,
Helen
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Minh
Top achievements
Rank 1
answered on 10 Sep 2011, 09:13 PM
Hi,

I was having some problem locating the subject as well. I received the following error

Microsoft JScript runtime error: Object doesn't support this property or method...on the line

var combo = eventArgs.get_gridDataItem().findControl("RadComboBoxArea");

 



 

 

<script type="text/javascript">

 

 

 

function OnClientDropDownOpening(sender, eventArgs)

 

{

alert(

 

"test");

 

 

 

 

var combo = eventArgs.get_gridDataItem().findControl("RadComboBoxArea");

 

combo.clearSelection();

}

 

 

</script>

 

0
Accepted
Kalina
Telerik team
answered on 15 Sep 2011, 12:55 PM
Hi Minh,

The OnClientDropDownOpening eventArgs object does not have reference to gridDataItem object.

Please try to get the RadComboBox object and clear the selection with this code:
<script type="text/javascript">
    function OnClientDropDownOpening(sender, eventArgs) {
        sender.clearSelection();
    }
</script>

Greetings,
Kalina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
Tags
Grid
Asked by
Minh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Minh
Top achievements
Rank 1
Helen
Telerik team
Kalina
Telerik team
Share this question
or