Allowing Custom Text for Only Specific Items

2 posts, 0 answers
  1. Chuck Lane
    Chuck Lane avatar
    4 posts
    Member since:
    Apr 2010

    Posted 27 Jul 2010 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 28 Jul 2010 Link to this post

    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.
Back to Top