Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Possible bug in ListGrid: grouping & invalidateCache

    When invalideCache is called on a grouped ListGrid, it loses its current filter criteria and grouping.

    I have created sample to show the problem using the adaptive filter example. Just replace the sample code at

    http://www.smartclient.com/docs/7.0rc2/a/system/reference/SmartClient_Explorer.html#adaptiveFilter

    with the code below:

    Code:
    isc.ListGrid.create({
        ID: "supplyList",
        width:500, height:300, alternateRecordStyles:true,
        dataSource: supplyItem,
        fields:[
            {name:"SKU"},
            {name:"description"},
            {name:"category"}
        ],
        autoFetchData: false,
        autoDraw: false
    });
    
    isc.VLayout.create({ members: [isc.Button.create({ title: "Invalidate cache", autoFit: true, click:"supplyList.invalidateCache()" }), supplyList ] });
    
    //supplyList.groupBy("category");
    supplyList.filterData({itemName:"adding"});
    CASE 1 - Behaves as expected
    When you run the example above, you will see a listgrid filtered programmatically. Push the "Invalidate cache" button and it will bring the same set of records.

    CASE 2 - Possible bug
    Uncomment the groupBy line at the end of the sample and run again. You will see a small set of records grouped by category. Push the Invalidate button and it will lose both grouping and current filter criteria. You will see many more records showing up. It is expected to bring the same records without removing grouping.

    As you see from the link above, the bug exists in SmartClient 7.0 RC2. I have tested the behavior in Chrome, FireFox, and IE 8.

    I would be glad if you could suggest a workaround.

    Thanks in advance.

    #2
    Found a workaround

    I found a workaround. I hope it helps others until it is fixed.

    Code:
    isc.ListGrid.create({
        ID: "supplyList",
        // WORKAROUND: invalidateCache does not work correctly when grouped
        fetchData: function(criteria, callback, requestProperties) {
            this.__lastFetchProps = { funcName: "fetchData", criteria: criteria, requestProperties: requestProperties };
            this.Super("fetchData", arguments)
        },
        filterData: function(criteria, callback, requestProperties) {
            this.__lastFetchProps = { funcName: "filterData", criteria: criteria, requestProperties: requestProperties };
            this.Super("filterData", arguments)
        },
        invalidateCache: function() {
            if (this.isGrouped) {
                var c = this.__lastFetchProps;
                this.Super(c.funcName, [c.criteria, null, c.requestProperties]);
            }
            else
                if (this.data && this.data.invalidateCache != null) return this.data.invalidateCache();
        },
        // WORKAROUND ENDS
        width:500, height:300, alternateRecordStyles:true,
        dataSource: supplyItem,
        fields:[
            {name:"SKU"},
            {name:"description"},
            {name:"category"}
        ],
        autoFetchData: false,
        autoDraw: false
    });
    
    isc.VLayout.create({ members: [isc.Button.create({ title: "Invalidate cache", autoFit: true, click:"supplyList.invalidateCache()" }), supplyList ] });
    
    supplyList.groupBy("category");
    supplyList.filterData({itemName:"adding"});

    Comment


      #3
      Can anyone confirm if this has been tackled in the latest release for smart client and smartgwt? I am still getting wrong grouping behavior when using the latest trunk code after invalidating the data in my list grids, but as I am working in smartgwt is impossible to verify if the proposed workaround can solve my issue. Anyone can propose a workaround for smartgwt as well?

      Comment

      Working...
      X