1. #1
    Sencha User tomalex0's Avatar
    Join Date
    Apr 2009
    Location
    San Jose, CA
    Posts
    589
    Vote Rating
    16
    tomalex0 will become famous soon enough

      0  

    Default List Store index is not sorted based on Grouping.

    List Store index is not sorted based on Grouping.


    Hi,

    I was trying to implement a simple Grouped list with search functionality. I have grouped based on First letter of lastname.

    Code:
    getGroupString : function(record) {
                            return record.get('lastName')[0];
                        },
    I came across problem first while grouping these names "Tommy Maintz" && "Tommy maintz" . Group with B and b are created.

    So i just gave

    Code:
    getGroupString : function(record) {
                            return record.get('lastName')[0].toUpperCase();
                        },
    Now the grouping worked fine. But it seems the name with small letter character is still at the last position of store.

    I have workaround for the issue that i came across.

    Code:
    var store;
    Ext.setup({
        tabletStartupScreen: 'tablet_startup.png',
        phoneStartupScreen : 'phone_startup.png',
        
        icon       : 'icon.png',
        glossOnIcon: false,
        
        onReady: function() {
            Ext.regModel('Contact', {
                fields: ['firstName', 'lastName']
            });
            store =  new Ext.data.JsonStore({
                        model  : 'Contact',
                        sorters: 'lastName',
                        getGroupString : function(record) {
                            return record.get('lastName')[0].toUpperCase();
                        },
                        data: [
                            {firstName: 'Tommy',   lastName: 'Maintz'},
                            {firstName: 'Rob',     lastName: 'dougan'},
                            {firstName: 'Ed',      lastName: 'spencer'},
                            {firstName: 'Jamie',   lastName: 'avins'},
                            {firstName: 'Aaron',   lastName: 'conran'},
                            {firstName: 'Dave',    lastName: 'kaneda'},
                            {firstName: 'Michael', lastName: 'mullany'},
                            {firstName: 'Abraham', lastName: 'elias'},
                            {firstName: 'Jay',     lastName: 'Robinson'},
                            {firstName: 'Tommy',   lastName: 'maintz'},
                            {firstName: 'Rob',     lastName: 'Dougan'},
                            {firstName: 'Ed',      lastName: 'Spencer'},
                            {firstName: 'Jamie',   lastName: 'Avins'},
                            {firstName: 'Aaron',   lastName: 'Conran'},
                            {firstName: 'Dave',    lastName: 'Kaneda'},
                            {firstName: 'Michael', lastName: 'Mullany'},
                            {firstName: 'Abraham', lastName: 'Elias'},
                            {firstName: 'Jay',     lastName: 'robinson'}
                        ]
                    });
            new Ext.Panel({
                layout:{
    		type:'vbox',
    		align:'stretch'
    	    },
                fullscreen:true,
    	    scroll:false,
    	    cls: 'demo-list',
                dockedItems: [{
    			xtype: 'toolbar',
    			scroll:false,
    			dock : 'top',
                            items:[{xtype: 'spacer'},
                            {
                                xtype      : 'textfield',
                                placeHolder: 'Search...',
                                listeners  : {
                                    scope: this,
                                    
                                    keyup: function(field) {
                                        var value = field.getValue();
                                        
                                        if (!value) {
                                            store.filterBy(function() {
                                                return true;
                                            });
                                        } else {
                                            var searches = value.split(' '),
                                                regexps  = [],
                                                i;
                                            
                                            for (i = 0; i < searches.length; i++) {
                                                if (!searches[i]) return;
                                                regexps.push(new RegExp(searches[i], 'i'));
                                            };
                                            
                                            store.filterBy(function(record) {
                                                var matched = [];
                                                
                                                for (i = 0; i < regexps.length; i++) {
                                                    var search = regexps[i];
                                                    
                                                    if (record.get('firstName').match(search) || record.get('lastName').match(search)) matched.push(true);
                                                    else matched.push(false);
                                                };
                                                
                                                if (regexps.length > 1 && matched.indexOf(false) != -1) {
                                                    return false;
                                                } else {
                                                    return matched[0];
                                                }
                                            });
                                        }
                                    }
                                }
                            },
                            {xtype: 'spacer'}]
                }],
                items:[{
                    xtype:'list',
                    id:'developerlist',
                    fullscreen:true,
                    itemTpl: '<tpl for="."><div class="contact">{firstName} <strong>{lastName}</strong></div></tpl>',
                    singleSelect: true,
                    indexBar:true,
                    grouped     : true,
                    store : store,
                    listeners:{
                        itemtap:function(list, index, item, e){
                            console.log(index);
                            console.log(Ext.encode(list.store.getAt(index).data));
                            console.log(list.getSelectedRecords());
                            console.log(list.getSelectedNodes())
                        }
                    }
                }]
            });
        }
    });
    Could someone look in to this.

  2. #2
    Sencha User
    Join Date
    Feb 2011
    Posts
    3
    Vote Rating
    0
    kenfodder is on a distinguished road

      0  

    Default


    Hi, I have the same problem. Could you share your workaround please?

  3. #3
    Sencha User
    Join Date
    Sep 2011
    Posts
    1
    Vote Rating
    0
    jbobrek is on a distinguished road

      0  

    Default


    I suggest working but not very beautiful solution. I've solved similar problem by providing unique identifier in my XTemplate for the list e.g.

    Code:
    <tpl for="."><div class="listline" id="{uid}">{name} in {city}</div></tpl>
    Now you can parse the el parameter which is a HTMLDivElement with following field and method:

    Code:
    el.firstChild.firstChild.getAttribute('id'))
    With the uid you can get the store record with:

    Code:
    Ext.getStore('some_store').getById(uid);

Similar Threads

  1. Configure Ext.List based on store's data?
    By mherger in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 8 Nov 2010, 10:42 AM
  2. ListViews index == Store index?
    By Dumas in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 10 Jul 2010, 7:15 AM
  3. z-index of ComboBox list vs z-index of Ext.menu.Menu
    By christocracy in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 1 Oct 2008, 10:05 AM

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar