[CLOSED] ComboBox default selected value

Page 1 of 3 123 LastLast
  1. #1

    [CLOSED] ComboBox default selected value

    Last edited by Daniil; Aug 03, 2012 at 6:42 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please replace:
    this.cmbOrganizacniJednotkyChange.Value = "778"
    this.cmbOrganizacniJednotkyChange.Text = "Display text for 778"
    with
    /* C# */
    this.cmbOrganizacniJednotkyChange.SelectedItems.Add(new Ext.Net.ListItem() { Value = "778" });
  3. #3
    Thanks, but still does't work :-(
  4. #4
    Please clarify what Ext.NET sources do you use?

    Do you bind numbers or strings into the Id ModelField?
    <ext:ModelField Name="Id" />
    Could you post a response of ZemeHledej.ashx?
  5. #5
    Hi
    ID is number,
    I make sample project whit this problem.
    http://www.dno.cz/WebSite1.zip
  6. #6
    Then please set up Raw mode for the ListItem
    new Ext.Net.ListItem() { Value = "778", Mode = ParameterMode.Raw }
  7. #7
    Bingo !
    Thank you.
  8. #8
    I was happy when it worked.
    But this works only in non paged listing. (sorry, but was not in the example)

    For example:
    Total records = 100,
    First page:
    {total:100,'items':[ {'Id':10,'Nazev':'xxxx1'},{'Id':11,'Nazev':'xxxx2'},{'Id':12,'Nazev':'xxxx3'},{'Id':13,'Nazev':'xxxx4'}]   }

    Second page:
    {total:100,'items':[ {'Id':14,'Nazev':'xxxx4'},{'Id':15,'Nazev':'xxxx5'},{'Id':16,'Nazev':'xxxx6'},{'Id':17,'Nazev':'xxxx7'}]   }
    If I select field from first page, its OK:
     this.ComboBox1.SelectedItems.Add(new Ext.Net.ListItem() { Value = "10", Mode = Ext.Net.ParameterMode.Raw  });
    but, I select field from second (and others) page its wrong:
     this.ComboBox1.SelectedItems.Add(new Ext.Net.ListItem() { Value = "14", Mode = Ext.Net.ParameterMode.Raw  });
    This sample is here:
    http://www.dno.cz/WebSite1.v2.zip

    <ext:Store ID="Store1" runat="server" AutoLoad="true">         
             <Proxy>
                <ext:AjaxProxy Url="Handler.ashx">
                    <ActionMethods Read="POST">
                    </ActionMethods>
                    <Reader>
                        <ext:JsonReader Root="items" TotalProperty="total">
                        </ext:JsonReader>
                    </Reader>
                </ext:AjaxProxy>
            </Proxy>
    
            <Model>
                <ext:Model ID="Model1" runat="server">
                    <Fields>
                        <ext:ModelField Name="Id" Type="Int" />
                        <ext:ModelField Name="Nazev" Type="String" />
                    </Fields>
                </ext:Model>
            </Model>
        </ext:Store>
    
         <ext:ComboBox ID="ComboBox1" ColSpan="5" runat="server"
            StoreID="Store1" DisplayField="Nazev" ValueField="Id" QueryMode="Remote" AutoSelect="true" PageSize="4">
            <ListConfig  LoadingText="Searching..." MinWidth="300" Border="true"></ListConfig>      
            <Listeners>
                                               
            </Listeners>                                                                       
        </ext:ComboBox>
    Test handler code:
    if (context.Request.Params["page"] != null && int.Parse(context.Request.Params["page"]) > 1)
            {
                context.Response.Write("{total:100,'items':[ {'Id':14,'Nazev':'xxxx4'},{'Id':15,'Nazev':'xxxx5'},{'Id':16,'Nazev':'xxxx6'},{'Id':17,'Nazev':'xxxx7'}]   }");
            }
            else 
            {
                context.Response.Write("{total:100,'items':[ {'Id':10,'Nazev':'xxxx1'},{'Id':11,'Nazev':'xxxx2'},{'Id':12,'Nazev':'xxxx3'},{'Id':13,'Nazev':'xxxx4'}]   }");
            }
  9. #9
    Quote Originally Posted by nikisbeta View Post
    But this works only in non paged listing.
    Yes, ComboBox can select some item only if a record assigned with that item is loaded into the ComboBox Store.

    So, if a record of that item is not loaded, even if you set up an item text, there, actually, won't be a selected item. The same is in Ext.NET v1.

    If it suites your needs, I can suggest to leave just
    this.cmbOrganizacniJednotkyChange.Text = "Display text for 778"
    removing
    this.cmbOrganizacniJednotkyChange.Value = "778"
    because the last causes an attempt to find a respective record. If not found, then no selected item.
  10. #10
    Thanks,
    this code display text in ComboBox:

    this.ComboBox1.Text = "Display text for 778";
    but, i need set value for ComboBox.
    In version 1.x a used this code:
    this.cmbOrganizacniJednotkyChange.Value = "778"
    this.cmbOrganizacniJednotkyChange.Text = "Display text for 778"
    this.cmbOrganizacniJednotkyChange.ValueNotFoundText =  "Display text for 778"
    In this version value "778" is not set. Value is text ("Display text for 778")
    Please, there is a solution to display the text "Display text for 778" and store the value "778"

    Maybe this is my problem :-(
    http://www.sencha.com/forum/showthre...s-in-empty-val


    thank you
Page 1 of 3 123 LastLast

Similar Threads

  1. ComboBox default value with razer
    By zhdl in forum 2.x Help
    Replies: 0
    Last Post: Aug 13, 2012, 9:59 AM
  2. Replies: 1
    Last Post: Mar 02, 2012, 11:36 AM
  3. Replies: 4
    Last Post: Sep 28, 2011, 9:57 AM
  4. [CLOSED] Default selected checkbox in gridview
    By speedstepmem3 in forum 1.x Premium Help
    Replies: 1
    Last Post: Aug 06, 2010, 11:57 AM
  5. [CLOSED] can the combobox in gridpanel appear by default?
    By LeeTheGreek in forum 1.x Premium Help
    Replies: 1
    Last Post: Nov 08, 2009, 11:33 PM

Tags for this Thread

Posting Permissions