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

[Solved] Setting default 'Select' to all radcomboboxes?

2 Answers 129 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
mac
Top achievements
Rank 1
mac asked on 04 Jan 2010, 08:28 PM
Hi
In my skin file i have the following. 

<

 

telerik:RadComboBox runat="server" AppendDataBoundItems="true"
 <
Items
<te
lerik:RadComboBoxItem Text="Select" Value="" /> 
</
Items
</t
elerik:RadComboBox

 

This works fine when I am using databound items to append to the drop down. I have come to scenario where I need to just use some static items in my control page. ie
  <telerik:RadComboBox ID="Arrangement" runat="server">  
<Items>  
<telerik:RadComboBoxItem Text="Service Contract" Value="Service Contract" />  
 <telerik:RadComboBoxItem Text="Contract" Value="Contract" />  
</Items>  
</telerik:RadComboBox>

I would like to return a result as
>Select
>Service Contract
>Contract

problem is that when I use the <items> tag in my skin file, I can't use it again in my code page.
Is there some other default value I can so as to avoid an empty drop down box on all my pages. I like seeing select as the default vs blank or the first items in lists.
mac

 

 

 

 

 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 05 Jan 2010, 03:15 PM
Hello mac,

RadComboBox does not provide means of globally defining a default Item that will be used from all RCBs across your web site/application.

Possible alternatives are to add the Item inline manually to all RCBs, inherit from RCB, add the Item in its OnInit override and use the inherited version instead of the original one. 

Another approach would be to define a JS function which runs through all RCBs on the page and inserts the default Item. Still you will need to include the JS file in each page containing a RCB that you would want to have the same default Item.

Do you think any of the above approach will be useful to you?

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.
0
mac
Top achievements
Rank 1
answered on 05 Jan 2010, 03:28 PM
Hi Simon
I think at this point in my project it would be better to just stay with my defaults in my global skin file, and then just add my static items in via a string or similar at the OnInit even. Thanks for clarifying though that it is not possible to have an 'initial value' or similar to the rcb.
mac
Tags
ComboBox
Asked by
mac
Top achievements
Rank 1
Answers by
Simon
Telerik team
mac
Top achievements
Rank 1
Share this question
or