Results 1 to 3 of 3

Thread: Filtering in NestedList + TreeStore

  1. #1

    Default Filtering in NestedList + TreeStore

    Hi All,

    I need a help on urgent basis. Can anyone help me that how can we filter the data in NestedList?

    Here is my code:-

    Category.json
    Code:
    [{
        "text": "Cars",
        "children": [{
            "text": "Asia",
            "children": [{
                "text": "Japan",
                "children": [{
                    "text": "Acura",
                    "leaf": true
                },{
                    "text": "Honda",
                    "leaf": true
                },{
                    "text": "Infiniti",
                    "leaf": true
                },{
                    "text": "Mitsubishi",
                    "leaf": true
                },{
                    "text": "Nissan",
                    "leaf": true
                },{
                    "text": "Scion",
                    "leaf": true
                },{
                    "text": "Subaru",
                    "leaf": true
                },{
                    "text": "Toyota",
                    "leaf": true
                }]
            },{
                "text": "Korea",
                "children": [{
                    "text": "Hyundai",
                    "leaf": true
                },{
                    "text": "Kia",
                    "leaf": true
                }]
            }]
        },{
            "text": "United Kingdom",
            "children": [{
                "text": "Aston Martin",
                "leaf": true
            },{
                "text": "Bentley",
                "leaf": true
            },{
                "text": "TVR",
                "leaf": true
            },{
                "text": "Land Rover",
                "leaf": true
            }]
        },{
            "text": "Europe",
            "children": [{
                "text": "Germany",
                "children": [{
                    "text": "Audi",
                    "leaf": true
                },{
                    "text": "BMW",
                    "leaf": true
                },{
                    "text": "Opel",
                    "leaf": true
                },{
                    "text": "Porsche",
                    "leaf": true
                },{
                    "text": "Volkswagen",
                    "leaf": true
                }]
            },{
                "text": "France",
                "children": [{
                    "text": "Citron",
                    "leaf": true
                },{
                    "text": "Renault",
                    "leaf": true
                },{
                    "text": "Peugeot",
                    "leaf": true
                }]
            }]
        },{
            "text": "United States",
            "children": [{
                "text": "Buick",
                "leaf": true
            },{
                "text": "Cadillac",
                "leaf": true
            },{
                "text": "Chevrolet",
                "leaf": true
            },{
                "text": "Chrysler",
                "leaf": true
            },{
                "text": "Ford",
                "leaf": true
            },{
                "text": "Jeep",
                "leaf": true
            },{
                "text": "Oldsmobile",
                "leaf": true
            },{
                "text": "Saturn",
                "leaf": true
            },{
                "text": "Tesla",
                "leaf": true
            }]
        }]
    },
    {
        "text": "Bus",
        "children": [{
            "text": "India",
            "children": [{
                "text": "A",
                "children": [{
                    "text": "B",
                    "leaf": true
                },{
                    "text": "C",
                    "leaf": true
                },{
                    "text": "D",
                    "leaf": true
                },{
                    "text": "E",
                    "leaf": true
                },{
                    "text": "F",
                    "leaf": true
                },{
                    "text": "G",
                    "leaf": true
                },{
                    "text": "H",
                    "leaf": true
                },{
                    "text": "I",
                    "leaf": true
                }]
            },{
                "text": "1111",
                "children": [{
                    "text": "Hyundai",
                    "leaf": true
                },{
                    "text": "Kia",
                    "leaf": true
                }]
            }]
        },{
            "text": "2222",
            "children": [{
                "text": "Aston Martin",
                "leaf": true
            },{
                "text": "Bentley",
                "leaf": true
            },{
                "text": "TVR",
                "leaf": true
            },{
                "text": "Land Rover",
                "leaf": true
            }]
        },{
            "text": "3333",
            "children": [{
                "text": "Germany",
                "children": [{
                    "text": "Audi",
                    "leaf": true
                },{
                    "text": "BMW",
                    "leaf": true
                },{
                    "text": "Opel",
                    "leaf": true
                },{
                    "text": "Porsche",
                    "leaf": true
                },{
                    "text": "Volkswagen",
                    "leaf": true
                }]
            },{
                "text": "France",
                "children": [{
                    "text": "Citron",
                    "leaf": true
                },{
                    "text": "Renault",
                    "leaf": true
                },{
                    "text": "Peugeot",
                    "leaf": true
                }]
            }]
        },{
            "text": "4444",
            "children": [{
                "text": "Buick",
                "leaf": true
            }
            ]
        }]
    }
    ]
    Model:Category.js
    Code:
    Ext.define('Sencha.model.Category', {
        extend: 'Ext.data.Model',
        config: {
            fields: [{
                name: 'text',
                type: 'string'
    }]
            }
        });
    Store: Categories.js
    Code:
    Ext.define('eLearing.store.Categories',
    {
        extend: 'Ext.data.TreeStore',
        requires: 'eLearing.model.Category',
        config:
        {
            model: 'eLearing.model.Category',
            type: 'tree',
            proxy: {
                type: 'ajax',
                url: 'app/data/Category.json',
                reader: {
                    type: 'json',
                    root: 'children'
                }
    
            }
        }
    }
        );
    app.js
    Code:
    var categoriesStore = Ext.getStore("Categories");
                categoriesStore.load();
    
                var nestedList = Ext.create('Ext.NestedList', {
                    modal: true,
                    hideOnMaskTap: true,
                    width: '400px',
                    height: '400px',
                    store: categoriesStore,
                    tpl: "<div>{text}</div>"
                });
                nestedList.add({
                    docked: 'top',
                    xtype: 'searchfield',
                    height: 100,
                    listeners: {
                        scope: this,
                        keyup: function(field) {
    
                            var value = field.getValue();
    
    ////// LOGIC WILL BE HERE.
    
    
    
                        }
                    }
    
    
    
                });
           Ext.Viewport.add(nestedList);

    Thanks,
    Manish

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    The TreeStore doesn't really support filtering. Each child list of the nestedlist you can try and filter them.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Mar 2013
    Posts
    16

    Default My XML looks like this.. and I want to use it in nestedList... I Got Parent but not

    <ns8:categoryHierarchy xmlns="http://www.deliverycube.com/mobilecube/rest/error" xmlns:ns2="http://www.deliverycube.com/mobilecube/rest/customer"xmlns:ns3="http://www.deliverycube.com/mobilecube/rest/payment" xmlns:ns4="http://www.deliverycube.com/mobilecube/rest/address"xmlns:ns5="http://www.deliverycube.com/mobilecube/rest/session" xmlns:ns6="http://www.deliverycube.com/mobilecube/rest/login"xmlns:ns7="http://www.deliverycube.com/mobilecube/rest/order" xmlns:ns8="http://www.deliverycube.com/mobilecube/rest/catalog"xmlns:ns9="http://www.deliverycube.com/mobilecube/rest/orderRequest" xmlns:ns10="http://www.deliverycube.com/mobilecube/rest/registration">
    <script id="tinyhippos-injected">
    if (window.top.ripple) { window.top.ripple("bootstrap").inject(window, document); }
    </script>


    <ns8:categoryHierarchyElement categoryId="topCatId1" displayName="Gift Ideas">
    <ns8:childCategories>
    <ns8:category id="subCatId11" displayName="For Him"/>
    <ns8:category id="subCatId12" displayName="For Her"/>
    <ns8:category id="subCatId13" displayName="Gift Certificates"/>

    </ns8:childCategories>



    </ns8:categoryHierarchyElement>


    <ns8:categoryHierarchyElement categoryId="topCatId2" displayName="Women's Apparel">
    <ns8:childCategories>
    <ns8:category id="subCatId21" displayName="Shirts"/>
    <ns8:category id="subCatId22" displayName="Pants"/>
    <ns8:category id="subCatId23" displayName="Dresses"/>
    <ns8:category id="subCatId24" displayName="Skirts"/>
    <ns8:category id="subCatId25" displayName="Shorts"/>
    <ns8:category id="subCatId26" displayName="Jackets"/>
    <ns8:category id="subCatId27" displayName="Accessories"/>

    </ns8:childCategories>



    </ns8:categoryHierarchyElement>


    <ns8:categoryHierarchyElement categoryId="topCatId3" displayName="Footwear">
    <ns8:childCategories>
    <ns8:category id="subCatId31" displayName="Women's Shoes"/>
    <ns8:category id="subCatId32" displayName="Men's Shoes"/>

    </ns8:childCategories>



    </ns8:categoryHierarchyElement>


    <ns8:categoryHierarchyElement categoryId="topCatId4" displayName="Home Store">
    <ns8:childCategories>
    <ns8:category id="subCatId41" displayName="Tables"/>
    <ns8:category id="subCatId42" displayName="Seating"/>
    <ns8:category id="subCatId43" displayName="Storage & Display"/>

    </ns8:childCategories>



    </ns8:categoryHierarchyElement>


    <ns8:categoryHierarchyElement categoryId="topCatId5" displayName="Bed & Bath">
    <ns8:childCategories>
    <ns8:category id="subCatId51" displayName="Towels and Linens"/>

    </ns8:childCategories>



    </ns8:categoryHierarchyElement>


    <ns8:categoryHierarchyElement categoryId="topCatId6" displayName="Home Accessories">
    <ns8:childCategories>
    <ns8:category id="subCatId61" displayName="Clocks"/>
    <ns8:category id="subCatId62" displayName="Radios"/>
    <ns8:category id="subCatId63" displayName="Cushions and Pillows"/>
    <ns8:category id="subCatId64" displayName="Glassware"/>
    <ns8:category id="subCatId65" displayName="Lamps and Lighting"/>
    <ns8:category id="subCatId66" displayName="Miscellaneous"/>

    </ns8:childCategories>



    </ns8:categoryHierarchyElement>



    </ns8:categoryHierarchy>


    My XML looks like this.. and I want to use it in nestedList... I Got Parent but not child... Why I don't know... Please Help....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •