[CLOSED] Combo Filter issue on type

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Combo Filter issue on type

    Hi,

    My issue is combo list is not filtered on typing text in combo.

    I have three combo fields, on first combo select it will filter the other two combo store.
    On second combo select, it will filter the third combo store.

    Now what happens is, for second and third combo, if i type, it will filter the store data and sort it accordingly. (the data displayed in the combo list will be filtered)

    But id i clear the store and try again for couple of times, it will not filter the store properly, means it shows the value to be selected but the store data which is shown in the list remains as it is. (the data displayed in the combo list is not filtered).

    I am attaching the sample code here. I am using the DLL of version 2.5.x

    As shown in image below it should hide records other than FQ 46
    Click image for larger version. 

Name:	FQ Filter.PNG 
Views:	97 
Size:	40.1 KB 
ID:	24901

    As shown in image below it should hide records other than Package 34

    Click image for larger version. 

Name:	Package Filter.PNG 
Views:	120 
Size:	34.3 KB 
ID:	24902

    For couple of times it happened that it filters properly and when you click on trigger or clear filter, it stops working.
    Also sometimes when you write something it wont filter, but when you click backspace, it starts filtering.
    I just want it to be filtered as and when i type anything in combo.

    Can you please look into the issue ASAP.
    Attached Files
    Last edited by fabricio.murta; May 12, 2017 at 6:24 PM.
  2. #2
    Hello @amitpareek!

    Could you please provide the code sample in [code][/code] tags? I see your attached txt file is pretty long, looks full of distractions (unrelated code to the problem happening), and also it has headers which suggest it needs a code behind file.

    Understanding that you want the fastest answer possible, I'm just letting know that the way you provided the test case is not going to help us help you in a timely manner. Usually simplified and short code samples helps us focus on what the problem really is and skip unrelated guesswork. You could minimize the test case and merge code behind in the page.

    Another thing. You posted on 4.x forums, but you mentioned you are using 2.5 DLL? So you meant to post this on 2.x forums? Shall we move your thread to 2.x forums? I see your example does not work on Ext.NET 4 at all.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello again! And the most probable answer to your problem is you are simply not handling number keys (as well as many other keys) when they are pressed (released, actually) on your TestExtractionProtocol.filterComboOnKeyUp() function.

    Check how when you type characters the list is updated and when you type numbers it is not. Likewise, typing "-" (hyphen) does not update the combo display.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  4. #4
    Hi Fabricio

    Thanks for your quick response.

    Yes you can move it to 2.x

    here is the sample code :
    <script type="text/javascript">
    
    
            TestExtractionProtocol = {
    
    
                ExpComboSelect: function (combo, records, eOpts) {
    
    
                    var cmVal = combo.getValue();
                    combo.getTrigger(0).show();
    
    
                    if (combo.id == "ExpClientListCombo1") {
                        App.storeEXPPackageList1.clearFilter();
                        App.ExpFQListCombo1.getStore().clearFilter();
    
    
                        App.storeEXPPackageList1.filter('ClientId', cmVal);
                        App.ExpFQListCombo1.getStore().filter('ClientId', cmVal);
    
    
                        App.ExpPackageListCombo1.reset();
                        App.ExpPackageListCombo1.focus();
                        App.ExpFQListCombo1.reset();
                    }
                    else if (combo.id == "ExpPackageListCombo1") {
                        App.ExpFQListCombo1.getStore().clearFilter();
                        App.ExpFQListCombo1.getStore().filter('PackageId', cmVal);
    
    
                        App.ExpFQListCombo1.reset();
                        App.ExpFQListCombo1.focus();
                    }
                    else if (combo.id == "ExpFQListCombo1") {
                    }
                },
    
    
                clearFilterExp: function (me) {
                    me.clearValue();
                    me.getTrigger(0).hide();
    
    
                    if (me.id == 'ExpClientListCombo1') {
    
    
                        App.storeEXPPackageList1.clearFilter();
                        App.ExpPackageListCombo1.getTrigger(0).hide();
                        App.ExpPackageListCombo1.clear();
    
    
                        App.ExpFQListCombo1.getStore().clearFilter();
                        App.ExpFQListCombo1.getTrigger(0).hide();
                        App.ExpFQListCombo1.clear();
                    }
                    else if (me.id == 'ExpPackageListCombo1') {
    
    
                        App.ExpFQListCombo1.getStore().clearFilter();
                        App.ExpFQListCombo1.getTrigger(0).hide();
                        App.ExpFQListCombo1.clear();
    
    
                        App.storeEXPPackageList1.clearFilter();
                        App.ExpPackageListCombo1.clear();
                    }
                    else if (me.id == "ExpFQListCombo1") {
                       
                        App.ExpFQListCombo1.clear();
    
    
                        window.setTimeout(function () {
                            if (App.ExpPackageListCombo1.getValue() != null && App.ExpPackageListCombo1.getValue().toString().trim() != "")
                                App.ExpFQListCombo1.getStore().filter("PackageId", App.ExpPackageListCombo1.getValue().toString());
                            else if (App.ExpClientListCombo1.getValue() != null && App.ExpClientListCombo1.getValue().toString().trim() != "")
                                App.ExpFQListCombo1.getStore().filter("ClientId", App.ExpClientListCombo1.getValue().toString());
                        }, 50);
                    }
    
    
                },
    
    
                filterComboOnKeyUp: function (combo, event, fn) {
    
    
                    if ((event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode >= 65 && event.keyCode <= 90) || event.keyCode == 8 || event.keyCode == 46) {
                        try {
                            combo.getTrigger(0).show();
                        }
                        catch (exc) {
                            console.log(exc);
                        }
                        if (event.keyCode == 8 || event.keyCode == 46) {
    
    
                            if (combo.getRawValue() == null || combo.getRawValue().trim() == "")
                                combo.getStore().clearFilter();
    
    
                            if (combo.id == "ExpPackageListCombo1") {
                                App.storeEXPPackageList1.clearFilter();
                                App.storeEXPPackageList1.filter("ClientId", App.ExpClientListCombo1.getValue().toString());
                            }
                        }
    
    
                        if (combo.id == "ExpPackageListCombo1") {
    
    
                            App.storeEXPPackageList1.clearFilter();
    
    
                            window.setTimeout(function () {
    
    
                                if (combo.getRawValue() != null && combo.getRawValue().trim() != "")
                                    App.storeEXPPackageList1.filter("PackageName", new RegExp(combo.getRawValue(), "i"));
    
    
                            }, 10);
                        }
    
    
                        else if (combo.id == "ExpFQListCombo1") {
    
    
                            window.setTimeout(function () {
    
    
                                if (App.ExpPackageListCombo1.getValue() != null && App.ExpPackageListCombo1.getValue().toString().trim() != "")
                                    combo.getStore().filter("PackageId", App.ExpPackageListCombo1.getValue().toString());
                                else
                                    combo.getStore().filter("ClientId", App.ExpClientListCombo1.getValue().toString());
    
    
                                window.setTimeout(function () {
    
    
                                    if (combo.getRawValue() != null && combo.getRawValue().trim() != "")
                                        combo.getStore().filter('FQName', new RegExp(combo.getRawValue(), "i"), true, false);
    
    
                                }, 100);
                            }, 100);
                        }
                    }
                },
    
    
                ExpComboBoxReady: function () {
    
    
                    clientList = []; a = 1;
                    packageList = []; b = 1;
                    fqList = []; c = 1;
    
    
                    for (var i = 1; i <= 10 ; i++) {
    
    
                        clientList.push({ ClientId: i, ClientName: "Client " + i });
    
    
                        for (var j = 1; j <= 10 ; j++) {
    
    
                            packageList.push({ ClientId: i, PackageId: b, PackageName: "Package " + b });
    
    
                            for (var k = 1; k <= 50 ; k++) {
    
    
                                fqList.push({ ClientId: i, PackageId: b, FQId: c, FQName: "FQ " + c });
                                c++;
                            }
                            b++;
                        }
                    }
                    
                    App.storeEXPClientList1.removeAll();
                    App.storeEXPClientList1.add(clientList);
    
    
                    App.storeEXPPackageList1.removeAll();
                    App.storeEXPPackageList1.add(packageList);
    
    
                    App.storeEXPFQList1.removeAll();
                    App.storeEXPFQList1.add(fqList);
    
    
                    App.ExpClientListCombo1.anyMatch = true;
                    App.ExpClientListCombo1.enableRegEx = false;
                    App.ExpClientListCombo1.bindStore(App.storeEXPClientList1);
                    App.ExpClientListCombo1.displayField = 'ClientName';
                    App.ExpClientListCombo1.valueField = 'ClientId';
                    //App.ExpClientListCombo1.getStore().sort();
    
    
                    App.ExpPackageListCombo1.anyMatch = true;
                    App.ExpPackageListCombo1.enableRegEx = false;
                    App.ExpPackageListCombo1.bindStore(App.storeEXPPackageList1);
                    App.ExpPackageListCombo1.displayField = 'PackageName';
                    App.ExpPackageListCombo1.valueField = 'PackageId';
                    //App.storeEXPPackageList1.sort();
    
    
                    App.ExpFQListCombo1.anyMatch = true;
                    App.ExpFQListCombo1.enableRegEx = false;
                    App.ExpFQListCombo1.bindStore(App.storeEXPFQList1);
                    App.ExpFQListCombo1.displayField = 'FQName';
                    App.ExpFQListCombo1.valueField = 'FQId';
                    //App.ExpFQListCombo1.getStore().sort();
                },
    
    
            }
    </script>
    
    <body>
        <form id="form1" runat="server">
            <div>
                <ext:ResourceManager ID="supportResourceManager" runat="server" DirectMethodNamespace="DM">
                </ext:ResourceManager>
    
    
                <ext:Panel runat="server" ID="pnlParent" ItemID="pnlParent" Height="500px" Border="true" Layout="FitLayout">
                    <Items>
                        <ext:Container runat="server" Layout="HBoxLayout" ID="cntClient">
                            <Items>
                                <ext:ComboBox ID="ExpClientListCombo1" EnableRegEx="true" ItemID="ExpClientListCombo1" QueryMode="Local" runat="server" DisplayField="ClientName"
                                    Width="280" LabelWidth="83" ValueField="ClientId" FieldLabel="Client Name" MatchFieldWidth="true" TypeAhead="true" MarginSpec="15 0 0 15">
                                    <Store>
                                        <ext:Store runat="server" ID="storeEXPClientList1" ItemID="storeEXPClientList1" Namespace="App" AutoLoad="true" AutoDataBind="true" AutoDestroy="false">
                                            <Model>
                                                <ext:Model runat="server" ID="modelclientlstEP" IDProperty="ClientId">
                                                    <Fields>
                                                        <ext:ModelField Name="ClientId"></ext:ModelField>
                                                        <ext:ModelField Name="ClientName"></ext:ModelField>
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                    <Listeners>
                                        <Select Fn="TestExtractionProtocol.ExpComboSelect"></Select>
                                        <TriggerClick Handler="TestExtractionProtocol.clearFilterExp(this);"></TriggerClick>
                                        <AfterRender Fn="TestExtractionProtocol.ExpComboBoxReady" Delay="1000"></AfterRender>
                                    </Listeners>
                                    <Triggers>
                                        <ext:FieldTrigger Icon="Clear" HideTrigger="true"></ext:FieldTrigger>
                                    </Triggers>
                                </ext:ComboBox>
    
    
                                <ext:ComboBox ID="ExpPackageListCombo1" ItemID="ExpPackageListCombo1" runat="server" QueryMode="Local" DisplayField="PackageName"
                                    Width="290" LabelWidth="95" ValueField="PackageId" FieldLabel="Package Name" MatchFieldWidth="true" TypeAhead="true" MarginSpec="15 0 0 15"
                                    EnableKeyEvents="true" AutoScroll="true">
                                    <Store>
                                        <ext:Store runat="server" ID="storeEXPPackageList1" ItemID="storeEXPPackageList1" Namespace="App" AutoLoad="true" AutoDataBind="true" AutoDestroy="false" SortOnFilter="true">
                                            <Model>
                                                <ext:Model runat="server" ID="modelpackagelstEP" IDProperty="PackageId">
                                                    <Fields>
                                                        <ext:ModelField Name="ClientId"></ext:ModelField>
                                                        <ext:ModelField Name="PackageId"></ext:ModelField>
                                                        <ext:ModelField Name="PackageName"></ext:ModelField>
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                    <Listeners>
                                        <Select Fn="TestExtractionProtocol.ExpComboSelect"></Select>
                                        <TriggerClick Handler="TestExtractionProtocol.clearFilterExp(this);"></TriggerClick>
                                        <KeyUp Fn="TestExtractionProtocol.filterComboOnKeyUp"></KeyUp>
                                    </Listeners>
                                    <Triggers>
                                        <ext:FieldTrigger Icon="Clear" HideTrigger="true"></ext:FieldTrigger>
                                    </Triggers>
                                </ext:ComboBox>
                                <ext:ComboBox ID="ExpFQListCombo1" ItemID="ExpFQListCombo1" runat="server" QueryMode="Local" Width="250" LabelWidth="25"
                                    DisplayField="FQName" ValueField="FQId" FieldLabel="FQ" MatchFieldWidth="true"
                                    MarginSpec="15 0 0 15" TypeAhead="true" >
                                    <Store>
                                        <ext:Store runat="server" ID="storeEXPFQList1" ItemID="storeEXPFQList1" Namespace="App" AutoLoad="true" AutoDataBind="true" AutoDestroy="false" SortOnFilter="true">
                                            <Model>
                                                <ext:Model runat="server" ID="modelfqlistEP" IDProperty="FQId">
                                                    <Fields>
                                                        <ext:ModelField Name="ClientId"></ext:ModelField>
                                                        <ext:ModelField Name="PackageId"></ext:ModelField>
                                                        <ext:ModelField Name="FQId"></ext:ModelField>
                                                        <ext:ModelField Name="FQName"></ext:ModelField>
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                    <Listeners>
                                        <Select Fn="TestExtractionProtocol.ExpComboSelect"></Select>
                                        <TriggerClick Handler="TestExtractionProtocol.clearFilterExp(this);"></TriggerClick>
                                        <KeyUp Fn="TestExtractionProtocol.filterComboOnKeyUp"></KeyUp>
                                    </Listeners>
                                    <Triggers>
                                        <ext:FieldTrigger Icon="Clear" HideTrigger="true"></ext:FieldTrigger>
                                    </Triggers>
                                </ext:ComboBox>
                            </Items>
                        </ext:Container>
                    </Items>
                </ext:Panel>
            </div>
        </form>
    </body>

    Also note that i am not using "TestExtractionProtocol.filterComboOnKeyUp".
    Its just for reference that, i have used this function because the filter didn't work on type.

    This code is written in aspx page and it does have aspx.cs (server side) page, but its empty. I have not used any server side method.

    I just want that on typing in combo it should filter automatically, so that i dont need to add any extra code to filter combo.

    Let me know if you need any more information.

    Thanks.
  5. #5
    Hello @amitpareek! Thanks for providing the test case!

    If you disable the custom function on KeyUp event, the filters work right. But I get you require the custom behavior to the filter when it is applied.

    But it can't be helped, if your custom function does not handle the keys, you could even return true from it, that it wouldn't work right as, when the non-handled keys are triggered, it would do the original job only -- which you are overriding for a reason.

    Look at line 88 of your code. That test. It should handle numeric keys. Possibly also symbol keys like %, -, =. Actually it should handle any keypress, or at least keys bound to "printable characters" that the original TypeAhead functions does.

    Well, unless I'm missing a point here. It really looks like the problem is just that test not handling -- at least in your test scenario -- the numeric key presses.

    Hope this helps! I hope being able to point the line number I'm talking about makes it clearer now. :)

    EDIT: oh yes, for the testing only, I commented out both KeyUp handlers you set up (lines 277 and 303) and the filtering as I type numbers works just fine.
    Last edited by fabricio.murta; Apr 10, 2017 at 5:20 PM.
  6. #6
    Can you please follow these steps to reproduce the issue which i got :

    1) Type anything in second combo and Clear it with trigger click (do this couple of times)
    2) Select any value in first combo and do the step 1.
    3) Now clear first combo and then type in combo 2.
    if you can do these steps couple of times you can see the issue in filter.

    Let me know if it still works for you.

Similar Threads

  1. Replies: 8
    Last Post: Jun 05, 2016, 7:10 PM
  2. [CLOSED] File Type Filter in FileUploadField
    By barnali in forum 3.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 05, 2016, 3:33 PM
  3. Replies: 9
    Last Post: Aug 11, 2015, 11:52 AM
  4. [CLOSED] How get combo input type in javascript?
    By mcfromero in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 18, 2012, 4:52 PM
  5. [CLOSED] Type Ahead in a Combo
    By CMA in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 17, 2009, 10:54 AM

Tags for this Thread

Posting Permissions