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

Allowing Custom Text for Only Specific Items

1 Answer 189 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Chuck Lane
Top achievements
Rank 1
Chuck Lane asked on 27 Jul 2010, 10:12 PM
I'm trying to                   Allow Custom text for only specific comboboxitems inside a radcombobox. Does anyone

<telerik:RadComboBox ID="MessageDropDown" runat="server" EmptyMessage="" AllowCustomText="true">
                    <Items>
                    <telerik:RadComboBoxItem Text="Approved By:"/>
                    <telerik:RadComboBoxItem Text="Lowest Fare Available"/>
</telerik   :RadComboBox>

So for example if I wanted to allow free text only on the Approved By: Entry, what's the easiest way to do this?

Thanks
Chuck

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Jul 2010, 07:16 AM
Hi Chuck,


If you want to allow user to type text only after selecting particular item (Approved By:), and for the rest of items want to make it ReadOnly, then try the following client code in OnClientSelectedIndexChanged event.

JavaScript:
<script type="text/javascript">
    function OnClientSelectedIndexChanged(sender, args) {
        var combo = sender;
        combo.trackChanges();
        if (args.get_item().get_text() == "Approved By:") {
            combo.get_inputDomElement().readOnly = false;
        }
        else {
            combo.get_inputDomElement().readOnly = true;
        }
        combo.commitChanges();
    }
</script>



-Shinu.
Tags
ComboBox
Asked by
Chuck Lane
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or