ComboBox with search functionality - setting saved values

  1. #1

    ComboBox with search functionality - setting saved values

    Hi!
    I have combo based on sample https://examples1.ext.net/#/Form/Com...Custom_Search/.
    I modified it to work as a address finder.
    User can enter zip code or city name and can choose one of displayed cities.

    It works well with user interaction.
    There is a problem with data display - how to set properly data to this combo?

    <ext:ComboBox ID="ComboBoxKodPocztowy" runat="server" FieldLabel="Miejscowosc" TypeAhead="false"
                                            LoadingText="Wyszukuje..." MinChars="1" AllowBlank="false" StoreID="StoreKodPocztowy"
                                            PageSize="20" Editable="true" DisplayField="KodMiasto" ValueField="Id" ItemSelector="div.list-item"
                                            TriggerAction="All" BlankText="Miejscowosc musi byc wypelniona" Select&#111;nfocus="true"
                                            ListWidth="500" ForceSelection="true">
                                            <Template ID="Template1" runat="server">
                                               <tpl for=".">
                                                     <div class="list-item">
                                                       {KodPocztowy}, &amp;nbsp;{MiejscowoscNazwa} : {WojewodztwoNazwa}, {Powiat}, {Ulica}
                                                       
    
                                               </tpl>
                                            </Template>
                                        </ext:ComboBox>

    In code behind:
    1) When I set

    ComboBoxKodPocztowy.SelectedItem.Value = valFromDb;
    - id of item is presented in combo box

    2) when I set

    ComboBoxKodPocztowy.SetRawValue("zip code and name of selected city");
    value combo text disappears when focus leave ComboBox....

    I know that problem is that when binding from database store has no data.
    How to handle such a situation (remember that there are thousands of cities in database.... - I can't initially fill store.....)?
    There is for example a listner where I can add one row to store when binding data to controls?
    Last edited by geoffrey.mcgill; Jan 11, 2011 at 10:30 PM.
  2. #2

    RE: ComboBox with search functionality - setting saved values

    Last edited by geoffrey.mcgill; Jan 11, 2011 at 10:31 PM.
  3. #3

    RE: ComboBox with search functionality - setting saved values

    Thank you for answer.
    I tried both solutions (query on Render) and this method
        ComboBox1.AddScript("{0}.setInitValue(\"{1}\");", ComboBox1.ClientID, "Columbine");
        ComboBox1.AddScript("{0}.doQuery('Columbine');", ComboBox1.ClientID);
    but my scenario is difficult: sometimes control is placed on page and is loaded every time, sometimes control is placed in window and rebinded many times using ajax methods on the same page. Both solutions have defects:
    - first, value is binded incorrectly when using in scenario without full page reload
    - second show expanded ComboBox list .....

    I'm lookind for something like this

    called from AjaxEvent/AjaxMethod

    void BindAddress(Address adres)
    {
    //simply add sobe object to Store - on server or client side
        cityStore.DataSource= new List<City>() {adres.City};
        comboBox.SelectedItem.Value = adres.City.Id;
        
    }
    I hope there is a simple and reliable solution...

Similar Threads

  1. [CLOSED] Sub Search for combobox
    By AnulekhaK in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 19, 2011, 9:31 AM
  2. custom search in combobox
    By aditya.murthy88@gmail.com in forum 1.x Help
    Replies: 0
    Last Post: Feb 05, 2011, 8:57 AM
  3. Combobox live search
    By Yannis in forum 1.x Help
    Replies: 0
    Last Post: Dec 09, 2009, 10:19 AM
  4. Missing functionality from ComboBox
    By dbassett74 in forum 1.x Help
    Replies: 3
    Last Post: May 14, 2009, 11:50 AM
  5. [CLOSED] Setting default values in linked comboboxes
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Mar 02, 2009, 3:26 AM

Posting Permissions