You found a bug! We've classified it as a bug in our system. We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User luisbug's Avatar
    Join Date
    Feb 2009
    Posts
    39
    Vote Rating
    0
    luisbug is on a distinguished road

      0  

    Default [CLOSED]Sorting bug in grids

    [CLOSED]Sorting bug in grids


    If i sort a grid in the GUI without defining a sorter in the store each row click handler returns a wrong record.
    I think it returns the record that would be in that position if the grid hadn't been sorted.

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    8,892
    Vote Rating
    102
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Could you please explain further and give us a test case?
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha User luisbug's Avatar
    Join Date
    Feb 2009
    Posts
    39
    Vote Rating
    0
    luisbug is on a distinguished road

      0  

    Default


    So i have this store
    Code:
    Ext.define('ABS.model.Abstract', {
    	extend	: 'Ext.data.Model',
    	idProperty: 'abstract_id',
    	fields 	: [
    		'abstract_id',
    		'submitter_id',
    		'theme_id',
    		'theme_name',
    		'theme_code',
    		'title',
    		'abstract',
    		'authors_simple',
    		'authors',
    		'status_id',
    		'status',
    		'evaluation_status_id',
    		'evaluation_status_name',
    		'presentation_type_id',
    		'presentation_type_name',
    		'your_evaluation',
    		'your_notes',
    		'ts_created',
    		'ts_updated',
    		'tags',
    		'votes_sum',
    		'votes_num',
    		'votes_avg'
    	],
    	
    	associations	: [
            { type: 'hasMany', model: 'Author',    name: 'authors' },
            { type: 'hasMany', model: 'Evaluation',    name: 'evaluations' }
        ],
    
    	proxy	: {
    		type		: 'direct',
    	    directFn	: ABS.Direct.juri.getAbstract,
    	    paramOrder	: ['token', 'id']
    	}
    });
    and this grid

    Code:
    Ext.define('ABS.view.abstract.Grid', {
    	extend	: 'Ext.grid.Panel',
    	alias	: 'widget.abstractgrid',
    	requires: ['Ext.grid.feature.Grouping'],
    	cls		: 'abstract-grid',
    	border	: false,
    	
    	initComponent : function() {
    		
    		var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
    			groupHeaderTpl: '{name} ({rows.length} Abstracts{[values.rows.length > 1 ? "s" : ""]})',
    			hideGroupedHeader: true,
    			// enableNoGroups: false,
    			startCollapsed: true
    		});
    		
    		Ext.apply(this, {
    			store		: 'Abstracts',
    			features	: [groupingFeature],
    			columns		: [
    				{
    					text		: 'Evaluation',
    					dataIndex	: 'your_evaluation',
    					align		: 'center',
    					width 		: 70,
    					renderer	: function(value, p, record) {
    						if (value != 'N/A') {
    							return '<b>' + value + '</b>';
    						} else {
    							return '<span style="color:#999">' + value + '</span>';
    						}
    					}
    				},
    				{
    					text		: 'Nr. Votes',
    					dataIndex	: 'votes_num',
    					align		: 'center',
    					width 		: 70,
    					renderer	: function(value, p, record) {
    						return '<b>' + ( value || 0 ) + '</b>';
    					}
    				},
    				{
    					text		: 'Votes Average',
    					dataIndex	: 'votes_avg',
    					align		: 'center',
    					width 		: 80,
    					renderer	: function(value, p, record) {
    						return '<b>' + ( value || 0 ) + '</b>';
    					}
    				},
    				{
    					text		: 'Theme',
    					dataIndex	: 'theme_name',
    					flex 		: 1
    				},
    				{
    					text		: 'Title',
    					dataIndex	: 'title',
    					flex		: 1
    				}
    			]
    		});
    		
    		this.callParent(arguments);
    	}
    });
    And in the controller have this:

    Code:
    	this.control({
    	        'abstractgrid': {
    				selectionchange	: this.onChangeSelection,
    	        },
    ... 
    
    
    onChangeSelection : function(view, selections) {
    		if (selections.length) {
    			item = selections.shift();
    			this.loadAbstract(item);
    		}
    	},
    It is a typical grid that show detail on row selection.
    Everything works fine, until i sort the grid by clicking in a column's header.
    It sorts fine, but the detail shown doesn't match the selected row. That is the first item in the selection array is not the item selected but instead the item that would be in that in that position before the sorting.

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,128
    Vote Rating
    516
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    I can't reproduce this, for example:

    Code:
    Ext.require('Ext.data.*');
    
    Ext.define('Item', {
        extend: 'Ext.data.Model',
        fields: ['a', 'b']
    })
    
    Ext.onReady(function() {
        
        Ext.create('Ext.grid.Panel', {
            renderTo: document.body,
            width: 400,
            height: 400,
            store: {
                model: 'Item',
                proxy: 'memory',
                data: [{
                    a: 1,
                    b: 2
                },{
                    a: 3,
                    b: 4
                },{
                    a: 5,
                    b: 6
                },{
                    a: 7,
                    b: 8
                }]
            },
            columns: [{
                dataIndex: 'a',
                header: 'A'
            }, {
                dataIndex: 'b',
                header: 'B'
            }],
            listeners: {
                itemclick: function(grid, rec){
                    console.log(rec.get('a'), rec.get('b'));
                }
            }
        });
        
    });
    1) Click on the row "1-2"
    2) Sort by column A, sort by column A again, so it's now sort DESC.
    3) Click on the row "7-8"

    Is this what you're saying?
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha User luisbug's Avatar
    Join Date
    Feb 2009
    Posts
    39
    Vote Rating
    0
    luisbug is on a distinguished road

      0  

    Default


    yes... :/
    maybe it's the grouping that is causing this...
    i can't do it now because i have a deadline closing in, but i'll try to screencast it later and reproduce it in a simpler example...

    Thanks anyway

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,128
    Vote Rating
    516
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Ok cool, I'll close this off, feel free to bump it if you can produce a test case.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  7. #7
    Sencha User ykey's Avatar
    Join Date
    Mar 2010
    Location
    USA
    Posts
    245
    Vote Rating
    27
    ykey has a spectacular aura about ykey has a spectacular aura about

      0  

    Default


    Evant do you notice the selection change event firing twice when making a selection (after the first selection)? Is this expected?

    Test case
    Code:
                   var counter = 0;
    		
    		Ext.onReady(function() {
    			var myData = [
    				['3m Co',                               71.72],
    				['Alcoa Inc',                           29.01],
    				['Altria Group Inc',                    83.81],
    				['American Express Company',            52.55],
    				['American International Group, Inc.',  64.13],
    				['AT&T Inc.',                           31.61],
    				['Boeing Co.',                          75.43],
    				['Caterpillar Inc.',                    67.27],
    				['Citigroup, Inc.',                     49.37],
    				['E.I. du Pont de Nemours and Company', 40.48],
    				['Exxon Mobil Corp',                    68.1],
    				['General Electric Company',            34.14],
    				['General Motors Corporation',          30.27],
    				['Hewlett-Packard Co.',                 36.53],
    				['Honeywell Intl Inc',                  38.77]
    			];
    			
    			// create the data store
    			var store = Ext.create('Ext.data.ArrayStore', {
    				fields: [
    				   {name: 'company'},
    				   {name: 'price',      type: 'float'}
    				],
    				data: myData
    			});
    
    			// create the Grid
    			var grid = Ext.create('Ext.grid.Panel', {
    				store: store,
    				height: 350,
    				width: 600,
    				title: 'Array Grid',
    				renderTo: Ext.getBody(),
    				listeners: {
    					selectionchange: function(view, selections) {
    						console.log(++counter, (selections.length === 0) ? 'No selection' : selections[0].data.company);
    					}
    				},
    				columns: [
    					{
    						text     : 'Company',
    						flex     : 1,
    						sortable : true,
    						dataIndex: 'company'
    					},
    					{
    						text     : 'Price',
    						width    : 75,
    						sortable : true,
    						renderer : 'usMoney',
    						dataIndex: 'price'
    					}
    				]
    			});
    
    		});
    Console Output
    Code:
    1 "American International Group, Inc."
    2 "No selection"
    3 "Alcoa Inc"
    4 "No selection"
    5 "General Electric Company"
    6 "No selection"
    7 "Hewlett-Packard Co."

  8. #8
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,128
    Vote Rating
    516
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Yes, this is expected. The selected row gets deselected, then the next row gets selected.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  9. #9
    Sencha User ykey's Avatar
    Join Date
    Mar 2010
    Location
    USA
    Posts
    245
    Vote Rating
    27
    ykey has a spectacular aura about ykey has a spectacular aura about

      0  

    Default


    Yea I just saw that you were using the itemclick event instead. Thanks for the reply.

Similar Threads

  1. Replies: 4
    Last Post: 10 May 2011, 12:27 AM
  2. Paging and Sorting grids...
    By rich_montana in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 17 Sep 2008, 5:02 AM
  3. Many grids in one domain, CookieProvider and sorting
    By Zed in forum Ext 2.x: Help & Discussion
    Replies: 8
    Last Post: 1 Dec 2007, 6:31 AM

Thread Participants: 3

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