[CLOSED] Combobox not contained value

  1. #1

    [CLOSED] Combobox not contained value

    Hi,

    I have a combobox editable. The user can write the first letters and the system autocompletes (I adjust the combobox code). In my application, when a combo isn't valid, it's shown on red.

    What I need is to mark the combobox as invalid when the value write by the user isn't on the combobox item list and, if possible, to clear the last value.

    Could you point me in the right direction, please?

    (I have tried to use the valueNotFoundText attribute (with no color), but the user didn't notice this fact).

    Thank u in advance.

     
    <ext:ComboBoxID="cmbDeliveryAgency"TriggerAction="All"AutoWidth="true"Width="175"
    ListWidth="350"StoreID="storeDeliveryAgencies"DisplayField="Name"ValueField="Id"
    runat="server"ItemSelector="div.search-item"TypeAhead="false"Mode="Local"
    HideTrigger="false"EmptyText="<%$ Resources: strings, Info_Results %>"
    AllowBlank="false"SelectOnFocus="true"Title="<%$ Resources: lblDeliveryAgency %>"ForceSelection="false">
    <TemplateID="Template2"runat="server">
    <Html>
    <tplfor=".">
    <divclass="search-item">
    <spanstyle="font-weight:bold;">{Name}</span>
    </div>
    </tpl>
    </Html>
    </Template>
    <SelectOnEvent="cmbDeliveryAgency_Change"/>
    </DirectEvents>
    <CustomConfig>
    <ext:ConfigItemName="anyMatch"Value="true"Mode="Raw">
    </ext:ConfigItem>
    </CustomConfig>
    </ext:ComboBox>
    Last edited by Daniil; Nov 24, 2010 at 6:56 AM. Reason: [CLOSED]
  2. #2
    Hi,

    There is a lot of <font> in the sample you provide. Please, re-format, see #3,
    http://forums.ext.net/showthread.php...ation-Required

    There are AllowBlank and BlankText properties. It could help to mark a combo as invalid if there is no value.

    Also the markInvalid() function can be useful for you.
    http://dev.sencha.com/deploy/dev/doc...er=markInvalid
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    There is a lot of <font> in the sample you provide. Please, re-format, see #3,
    http://forums.ext.net/showthread.php...ation-Required

    There are AllowBlank and BlankText properties. It could help to mark a combo as invalid if there is no value.

    Also the markInvalid() function can be useful for you.
    http://dev.sencha.com/deploy/dev/doc...er=markInvalid

    Thank you for your quick response. I have reformated my previous message.

    Yeah, my combobox was already as AllowBlank = false. However, my problem is in the following case:

    1. You select a valid item (for example, "1").
    2. After this, the user type a string that doesn't match (for example, "2") with any item of the combobox list.

    In this case, the combo value is "1", so the combo isn't blank and no validation. If the user doesn't notice the "valueNotFoundText" text on the combo, he could think the value "2" was allright. What I need in this case is to be able to alert the user (with an alert message, for example)". The value introduced doesn't exists in the list".
  4. #4
    Hi,

    I would suggest you to handle the Store's Load event.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Import Namespace="System.Linq" %>
     
    <script runat="server">
        private object[] MyData =
            new object[]
            {
                new object[] { "a" },
                new object[] { "b" },
                new object[] { "c" },
                new object[] { "a1" },
                new object[] { "b1" },
                new object[] { "b2" }
            };
     
        protected void Store_Refresh(object sender, StoreRefreshDataEventArgs e)
        {
            Store store = sender as Store;
            string filter = e.Parameters["query"];
            var filteredList = from x in MyData
                               where (x as object[])[0].ToString().StartsWith(filter)
                               select x;
            store.DataSource = filteredList;
            store.DataBind();
        }
    </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"
            DisplayField="test"
            ValueField="test"
            TypeAhead="false"
            LoadingText="Searching..."
            MinChars="1"
            HideTrigger="true">
            <Store>
                <ext:Store
                    runat="server"
                    AutoLoad="false"
                    OnRefreshData="Store_Refresh">
                    <Proxy>
                        <ext:PageProxy />
                    </Proxy>
                    <Listeners>
                        <Load Handler="if (records.length == 0) { ComboBox1.markInvalid('Value is not found'); }"/>
                    </Listeners>
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
        </ext:ComboBox>
        </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] DirectMethod call from page contained in a masterpage
    By egvt in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: May 18, 2012, 5:36 PM
  2. Replies: 5
    Last Post: Mar 29, 2012, 9:31 PM
  3. [CLOSED] Print image contained in a panel.
    By stoque in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 23, 2011, 6:07 PM
  4. Replies: 0
    Last Post: Aug 03, 2011, 10:27 PM
  5. Replies: 1
    Last Post: Nov 05, 2009, 8:23 AM

Tags for this Thread

Posting Permissions