Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-1982 in a recent build.
  1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    26
    Vote Rating
    0
    tachtevrenidis is on a distinguished road

      0  

    Default List shows empty text upon store load with CRUD proxy

    List shows empty text upon store load with CRUD proxy


    First of all this 'sortof' has to do with this: http://www.sencha.com/forum/showthre...hlight=isModel

    I have my own proxy which looks like this:

    Code:
    Ext.define('TestApp.proxy.TestProxy', {    extend : 'Ext.data.Proxy',
    
    
        create : function(operation, callback, scope) {
            console.log('proxy create');
        },
        update : function(operation, callback, scope) {
            console.log('proxy update');
        },
        destroy : function(operation, callback, scope) {
            console.log('proxy destroy');
        },
        read : function(operation, callback, scope) {
            console.log('proxy read');
    
    
            operation.setStarted();
    
    
            var items = [];
    
    
            var item = Ext.create('TestApp.model.TestModel', {
                id : 1,
                value : 'item1'
            });
    
    
            items.push(item);
    
    
            operation.setResultSet(Ext.create('Ext.data.ResultSet', {
                records : items,
                total : items.length,
                success : true,
                loaded : true
            }));
    
    
            operation.setSuccessful();
            operation.setCompleted();
    
    
            callback.call(scope || this, operation);
        }
    });
    When I call store.load() I get 'no records found' pretty much the empty text verbiage although I am loading the list with 1 element. This is with todays build. When I traced through the code I see that this:

    Code:
    var me = this,
                records = operation.getRecords(),            resultSet = operation.getResultSet(),             successful = operation.wasSuccessful();
    which is the beginning of the 'onProxyLoad' method. Tracing through the code, 'records' is null because first of all I don't see a .getRecords() method in class 'Operation' in the documentation. I am expecting something like:
    Code:
    records = operation.getResultSet().getRecords();
    based on the documentation and how I am loading the records in my read method. If I change the onProxyLoad to this, it works! Bottom line, no matter what operation.getRecords() is null which means that there are no items in the list which results in displaying the empty text. In B2 there was an issue with trying to load a 'null' array (which is not what I am doing although this is what it thinks I am doing) so it would throw the 'isModel is null' error (see the thread from the link I pasted on top).

    Another way to fix it for now it to load the list of items twice in my read method:

    Code:
    operation.setRecords(items);
     
           operation.setResultSet(Ext.create('Ext.data.ResultSet', {
                records : items,
                total : items.length,
                success : true,
                loaded : true
            }));
    but again I don't see 'operation.setRecords()' in the Sencha Touch 2 API Docs. Nevertheless this works although it seems superfluous. Is this a bug?

  2. #2
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    18
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    Thank you for the report.

    Sencha Inc

    Jamie Avins

    @jamieavins

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    10
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default


    Hi tachtevrenidis

    We fixed this inconvenience and updated the Operation.getRecords() method to return the records from the resultSet if they are not defined on the operation itself. It will be part of the next release (which will be out very soon). We also added docs for the setRecords and getRecords methods on the Operation class. Thanks for the debugging and the report.

Thread Participants: 2