Results 1 to 2 of 2

Thread: Strange behaviour while summary grouping grid by float/int field

    Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha Premium Member fl.borovsky's Avatar
    Join Date
    Jul 2013
    Vote Rating

    Default Strange behaviour while summary grouping grid by float/int field

    There is an implementation bug in Store class, I provide working solution for it:
    old extjs code:

    new code:

    reproduce bug:
    1. create model with number field
    2. create data with 3 records having that field equals to 0, 0.5, 1 respectively
    3. create grid panel with groupingsummary feature and group by that field

    expected result:

    given result:

    what is wrong? everywhere should be "count: 1" and where is last summary row? it disapeared.
    My explamation:
    1. Group creation process creates a map aggregated field -> group instance
    2. It iterates through all records and checks if the key from record exists in group-by-key map
    3. if groups.get(groupValue) is null, new group will be created, otherwise existing group will be fetched and record added to the group

    The problem is, that groups is a MixedCollection and there is get method used to check if group exists.
    Note that get method has two features: it looks for a key but if doesn't exist and the key is an number, the item at specified index (=key) will be returned

    Trace following example:
    three records with fields: 0, 0.5, 1
    below is pseudo code for each groups.get(groupValue) execution and next if(group){create new gruop} statement
    >>groups: empty array
    1. does gruop exist of key 0? no. 0 is number? yes. so return [0] which is undefined
    >>groups: [0: group of key 0]
    2. does group exist of key 0.5? no. 0.5 is number? yes. so return [0.5] which is not an index and is undefined
    >>groups: [0: group of key 0, 1: group of key 0.5]
    3. does group exist of key 1? no. 1 is number? yes so return [1] which exists and is group of key 0.5
    >>groups: [0: group of key 0, 1: group of key 0.5]

    so because of wrong usage of mixed collection api we created two groups instead of three and last record was assigned to second group instead of new-third

    As written in docs, getByKey method never tracks argument as index so it is safe in opposite to get() method.


    without my fix:

    with my fix:

    Issue observed in 4.2.0 and 4.2.1. Tested OK in 4.1.3.

    Inline test case:
    Ext.define('TestResult', {
        extend: '',
        fields: ['student', 'subject', {
            name: 'mark',
            type: 'number'
    Ext.create('Ext.grid.Panel', {
        width: 200,
        height: 240,
        renderTo: document.body,
        features: [{
            groupHeaderTpl: 'Subject: {name}',
            ftype: 'groupingsummary'
        store: {
            model: 'TestResult',
            groupField: 'mark',
            data: [{
                student: 'Student 1',
                subject: 'Math',
                mark: 0
                student: 'Student 1',
                subject: 'Science',
                mark: .5
                student: 'Student 2',
                subject: 'Math',
                mark: 1
        columns: [{
            dataIndex: 'student',
            text: 'Name'
        }, {
            dataIndex: 'mark',
            text: 'Mark',
            summaryType: 'count'
    Last edited by slemmon; 2 Aug 2013 at 1:25 PM. Reason: additional test info

  2. #2
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Boise, ID
    Vote Rating


    Thanks for the report! I have opened a bug in our bug tracker.

Tags for this Thread

Posting Permissions

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