[CLOSED] Combobox with store and pageproxy

  1. #1

    [CLOSED] Combobox with store and pageproxy

    Hi,
    I has a combobox configured like this:
    <ext:ComboBox ID="cbCitizen" runat="server" DisplayField="FullName" ValueField="ID_Citizen"
                                    TypeAhead="false" LoadingText="Searching..." Width="500" FieldLabel="Citizen"
                                    PageSize="10" HideTrigger="true" MinChars="3" ItemSelector="div.search-item">
                                     <Triggers>
                                        <ext:FieldTrigger Icon="Clear" Qtip="Remove selected" />
                                    </Triggers>
                                    <Listeners>
                                        <TriggerClick Handler="this.removeByValue(this.getValue());this.clearValue();" />
                                    </Listeners>
                                    <Store>
                                        <ext:Store ID="stCitizenearch" runat="server" AutoLoad="false" OnRefreshData="stCitizenSearcher_RefreshData">
                                            <Proxy>
                                                <ext:PageProxy>
                                                </ext:PageProxy>
                                            </Proxy>
                                            <Reader>
                                                <ext:JsonReader>
                                                    <Fields>
                                                        <ext:RecordField Name="ID_Citizen" Type="Int" />
                                                        <ext:RecordField Name="Name" Type="String" />
                                                        <ext:RecordField Name="Surname" Type="String" />
                                                        <ext:RecordField Name="CodFiscale" Type="String" />
                                                        <ext:RecordField Name="NTesseraSanitaria" Type="String" />
                                                        <ext:RecordField Name="FullName" Type="String" />
                                                    </Fields>
                                                </ext:JsonReader>
                                            </Reader>
                                        </ext:Store>
                                    </Store>
                                    <Template ID="Template1" runat="server">
                                        <Html>
                                            <tpl for=".">
                              <div class="search-item">
                                 <h3><span>{FullName}</span>({CodFiscale})</h3>
                                 Tessera sanitaria: {NTesseraSanitaria}
                              </div>
                           </tpl>
                                        </Html>
                                    </Template>
                                </ext:ComboBox>
    During the search I have no problem, but when I try to set a selected item when combo is empty the combo display only a value of item that I try to add.
    My code to select an item is
    Example 1:
    cbCitizen.SelectedItem.Value = 1;
    cbCitizen.SelectedItem.Text = "John Writers"
    Example 2:
     cbCitizen.Items.Add(new Ext.Net.ListItem("John Writers", 1));
     cbCitizen.SetValue(1);"
    After this test the results is the same. he text is always = 1

    Thanks for support
    Regards
    Last edited by Daniil; Apr 25, 2011 at 9:00 AM. Reason: [CLOSED]
  2. #2
    Hi,

    1. This code causes compiler erros:
    cbCitizen.SelectedItem.Value = 1;
    cbCitizen.Items.Add(new Ext.Net.ListItem("John Writers", 1));
    because expected type is string, not int.

    2. Adding in Items collection doesn't make any sense during DirectEvent. Please use .AddRecord();

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.ComboBox1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "1", "item1" },
                    new object[] { "2", "item2" }
                };
                store.DataBind();
            }
        }
    
        protected void Add(object sender, DirectEventArgs e)
        {
            this.ComboBox1.GetStore().AddRecord(new { value = "3", text = "item3"  });
            this.ComboBox1.SetValue(3);
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:ComboBox ID="ComboBox1" runat="server">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="value" />
                                <ext:RecordField Name="text" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
        </ext:ComboBox>
        <ext:Button runat="server" Text="Add" OnDirectClick="Add" />
        </form>
    </body>
    </html>

Similar Threads

  1. Replies: 14
    Last Post: Nov 16, 2012, 11:01 AM
  2. TabPanel and Store with PageProxy?
    By dmoore in forum 1.x Help
    Replies: 4
    Last Post: Aug 25, 2011, 4:40 PM
  3. [CLOSED] PageProxy
    By jeybonnet in forum 1.x Premium Help
    Replies: 1
    Last Post: Feb 21, 2011, 4:26 PM
  4. Multi Store PageProxy
    By andreydruz in forum 1.x Help
    Replies: 1
    Last Post: Jan 08, 2011, 1:28 PM
  5. [CLOSED] Timeout for PageProxy
    By macap in forum 1.x Premium Help
    Replies: 7
    Last Post: Oct 07, 2010, 2:20 PM

Posting Permissions