[CLOSED] Custom value in combobox

  1. #1

    Custom value in combobox

    How to allow editable combobox to return custom value. For example if value selected, return selected. If value entered and it doesn't exist in store return entered text as value.
    Last edited by bakardi; Jun 28, 2011 at 1:56 PM.
  2. #2
    Hi,

    Please set ForceSelection="false" for the combo
  3. #3
    Looks like it doesn't work in my case:
    <ext:PropertyGridParameter Name="TR/CR Section #"  Value="">
                                        <Renderer Handler="return (value != '' && #{cbSectionStore}.getById(value) != null)?#{cbSectionStore}.getById(value).data.Section: #{hdnSectionFix}.getValue();" />
                                        <Editor>
                                            <ext:ComboBox ID="cbSection" runat="server" DisplayField="Section" ValueField="ID" ItemSelector="div.cmb-item" ListWidth="350" ForceSelection="false">
                                                <Store>
                                                    <ext:Store ID="cbSectionStore" runat="server" AutoLoad="false" OnRefreshData="SectionRefresh">
                                                        <BaseParams>
                                                            <ext:Parameter Name="Chapter" Value="chapter" Mode="Raw" />
                                                        </BaseParams>
                                                        <Reader>
                                                            <ext:JsonReader IDProperty="ID">
                                                                <Fields>
                                                                    <ext:RecordField Name="ID" Mapping="ID" Type="int" />
                                                                    <ext:RecordField Name="Section" Mapping="Section" />
                                                                    <ext:RecordField Name="SectionTitle" Mapping="SectionTitle" Type="String" />
                                                                </Fields>
                                                            </ext:JsonReader>
                                                        </Reader>
                                                    </ext:Store>
                                                </Store>
                                                <Listeners>
                                                    <Focus Handler="this.onTriggerClick();" Delay="100" />
                                                </Listeners>
                                                 <Template ID="Template6" runat="server">
                                                    <Html>
                                                        <tpl for=".">
                                                              <div class="cmb-item"><b>{Section}</b><br />{SectionTitle}</div>
                                                        </tpl>
                                                    </Html>
                                                </Template>
                                            </ext:ComboBox>
                                        </Editor>
                                    </ext:PropertyGridParameter>
  4. #4
    Hi,

    You should review the Renderer.

    For example, try:
    <Renderer Handler="return value;" />
    You will see a value you type.
  5. #5
    I did. Looks like even with ForceSelection="false" it forsing to select value
  6. #6
    It doesn't force selection for me.
  7. #7
    I have created an example. Looks like if we do refresh store for combobox, forceselection doesn't work:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ABCImaging.BPOL.Main.WebForm1" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!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 id="Head1" runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager runat="server" />
        <ext:PropertyGrid runat="server" Width="200" AutoHeight="true">
            <Source>
                <ext:PropertyGridParameter Name="Prop1" Value="prop1">
                    <Editor>
                        <ext:ComboBox runat="server" ForceSelection="false">
                            <Items>
                                <ext:ListItem Text="Item 1" Value="1" />
                                <ext:ListItem Text="Item 2" Value="2" />
                            </Items>
                            <Listeners>
                                <Select Handler="#{cbJopaStore1}.reload();" />
                            </Listeners>
                        </ext:ComboBox>
                    </Editor>
                </ext:PropertyGridParameter>
                <ext:PropertyGridParameter Name="Prop2" Value="">
                    <Editor>
                        <ext:ComboBox ID="cbJopa" runat="server" ValueField="Key" DisplayField="Value" ItemSelector="div.cmb-item" ForceSelection="false">
                            <Store>
                                <ext:Store ID="cbJopaStore1" runat="server" AutoLoad="false" OnRefreshData="SectionRefresh" >
                                    <Reader>
                                        <ext:JsonReader IDProperty="Key">
                                            <Fields>
                                                <ext:RecordField Name="Key" Mapping="Key" Type="int" />
                                                <ext:RecordField Name="Value" Mapping="Value" />
                                            </Fields>
                                        </ext:JsonReader>
                                    </Reader>
                                </ext:Store>
                            </Store>
                            <Template ID="Template6" runat="server">
                                <Html>
                                    <tpl for=".">
                                                              <div class="cmb-item"><b>{Key}</b><br />{Value}</div>
                                                        </tpl>
                                </Html>
                            </Template>
                        </ext:ComboBox>
                    </Editor>
                </ext:PropertyGridParameter>
            </Source>
        </ext:PropertyGrid>
        </form>
    </body>
    </html>
     protected void SectionRefresh(object sender, StoreRefreshDataEventArgs e)
            {
                var source = new KeyValuePair<int, string>[2];
                source[0] = new KeyValuePair<int, string>(1, "1");
                source[1] = new KeyValuePair<int, string>(2, "2");
                cbJopaStore1.DataSource = source;
                cbJopaStore1.DataBind();
            }
  8. #8
    I can type any value into the second ComboBox either before .reload() or after.

    What exactly are your steps to reproduce?

Similar Threads

  1. [CLOSED] Custom Search Combobox
    By deejayns in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 02, 2011, 1:40 PM
  2. [CLOSED] Custom ComboBox loading
    By kenanhancer in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 24, 2011, 9:37 AM
  3. [CLOSED] Custom Search Combobox
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 04, 2010, 7:29 PM
  4. [CLOSED] [1.0] ComboBox Custom Search
    By Ben in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 01, 2009, 7:00 PM
  5. [CLOSED] custom search get value of combobox
    By idrissb in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Oct 05, 2009, 5:25 PM

Posting Permissions