ASPxCombobox, Allow user input and dropdown selection

I'm using devexpress ASPxComboBox, however I wanted to know how I can allow the user to enter values(in case it is not in the list) or choose from a dropdown list.

An example would be great!

Thanks,

Tim

Answers


I have written a code which allows you to add a new Item to the ComboBox's Items collection if the Enter key is pressed.

   <script type="text/javascript">
    function findItemByText(editor, newText) {
        for(var i = 0; i< editor.GetItemCount(); i++)
            if(editor.GetItem(i).text == newText)
                return true;
        return false;
    }   

    function tryAddNewItem(editor, newText) {
        if(!findItemByText(editor, newText))
            editor.AddItem(newText);
    }
   </script>

...

<dx:ASPxComboBox ID="ASPxComboBox1" runat="server" DropDownStyle="DropDown" ValueType="System.String"
            Width="286px">
            <Items>
                <dx:ListEditItem Text="Item 0" Value="0" />
                <dx:ListEditItem Text="Item 1" Value="1" />
            </Items>
            <ClientSideEvents KeyPress="function(s,e) {
                if(e.htmlEvent.keyCode == 13) 
                    tryAddNewItem(s, s.GetText());
            }"/>


Need Your Help

Compare lines in a file

perl hash dataset large-files

I have a large dataset that looks like this:

getBounds() of defined group of markers

javascript leaflet mapbox

I'm wanting to zoom a mapBox map to a specific group of markers based on a shared property.