1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    7
    Vote Rating
    0
    fdalesio is on a distinguished road

      0  

    Default Problem reading total property

    Problem reading total property


    Hello,
    I'm having a problem reading the total property from an Ext.Direct read operation (4.2.1).
    It seems that the only way to get the total property working is by using this override:
    PHP Code:
    Ext.define('Override.data.proxy.Direct', {
         
    override'Ext.data.proxy.Direct',    
         
    extractResponseDataExt.identityFn
    }); 
    This is the model configuration
    PHP Code:
    Ext.define('Antrag', {
        
    fields: ['id''name'...],
        
    proxy: {
            
    type'direct',
            
    api: {
                
    createAntrag.create,
                
    readAntrag.read,
                
    updateAntrag.update,
                
    destroyAntrag.destroy
            
    },
            
    reader: {
                
    type'json',
                
    root'result',
                
    totalProperty'total'
            
    }
        }
    }); 
    And this is the response from server
    PHP Code:
    0: {
        
    action"Antrag"
        
    method"read"
        
    result: [{id:1652betriebsnummer:4444444aktenzahl:4444familienname:ciaovorname:ciaoort:, plz:,},]
        
    tid1
        total
    447
        type
    "rpc"

    Without the override, the reader receives only the records, instead of the whole response object.

    It seems so strange to me, because I have other applications where the total works as expected and I can't figure out what's going wrong here...

    I also fear that the override will cause unexpected problems somewhere else...
    Can someone help me understanding this problem?

    Thank you

    Regards


    Francesco

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    The actual response is in the result where you just have an array. Your response should really be:

    Code:
    0: {
        action: "Antrag"
        method: "read"
        result: {
            total: 447
            result : [{id:1652, betriebsnummer:4444444, aktenzahl:4444, familienname:ciao, vorname:ciao, ort:, plz:,…},…]
        },
        tid: 1
        type: "rpc"
    }
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    7
    Vote Rating
    0
    fdalesio is on a distinguished road

      0  

    Default


    Hello mitchellsimoens,
    thank you!

    Changing the way the server responses solved the problem

    Regards


    Francesco

  4. #4
    Sencha User
    Join Date
    Nov 2011
    Posts
    3
    Vote Rating
    0
    bruno.rothbaecher is on a distinguished road

      0  

    Default I have the same problem

    I have the same problem


    I've the same problem.

    Here is my code:
    Code:
    <script>
    Ext.require([
        'Ext.direct.*',
        'Ext.data.*',
        'Ext.grid.*',
        'Ext.toolbar.Paging',
    ]);
    
    Ext.define('Projects',{
        extend: 'Ext.data.Model',
        fields: ['ID','Company','Division','User','Description','ProjectStatus','Created','OfferNumber','ProjectNumber',
            'CustomerNumber','Languages','Deadline','Remark','Folder'],
        reader:{type: 'json', root: 'result', totalProperty: 'total'}
    })
    
    Ext.ns("Ext.app");
    Ext.app.REMOTING_API = {"url":"<? echo $this->createUrl('projects/getData')?>","type":"remoting",
                "actions":{"GetData":[{"name":"getGrid","len":1}]}};
    
    Ext.onReady(function(){
        Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);
        var store = Ext.create('Ext.data.DirectStore',{
            model: 'Projects',
            remoteSort: true,
            autoLoad: true,
            pageSize: 25,
            proxy:{
                type: 'direct',
                directFn: 'GetData.getGrid',
            }
        });
        
        Ext.create('Ext.container.Viewport', {
            layout: {
                type: 'border',
                padding: '0 0 0 0'
            },
            items: [{
                id: 'panelHeader',
                xtype: 'box',
                region: 'north',
                height: 45,
                html: '[i]-gate'
            },{
                xtype: 'gridpanel',
                title: 'Projekte',
                region: 'center',
                editable: false,
                dockedItems:[{
                    xtype: 'toolbar',
                    dock: 'top',
                    items: [{
                        text: 'Neues Projekt'
                    }]
                }],
                store: store,
                columns:[{
                    dataIndex: 'ID',
                    text: 'ID',
                    width: 100,
                    hidden: true
                },{
                    dataIndex: 'Company',
                    text: 'Firma',
                    width: 100
                },{
                    dataIndex: 'Division',
                    text: 'Unternehmensbereich',
                    flex: 1
                },{
                    dataIndex: 'User',
                    text: 'Benutzer',
                    width: 150
                },{
                    dataIndex: 'Description',
                    text: 'Auftragstitel',
                    flex: 1
                },{
                    dataIndex: 'ProjectStatus',
                    text: 'Status',
                    width: 100
                },{
                    dataIndex: 'Created',
                    text: 'Erstelldatum',
                    width: 100
                },{
                    dataIndex: 'OfferNumber',
                    text: 'Angebots-Nr',
                    width: 100
                },{
                    dataIndex: 'ProjectNumber',
                    text: 'Projekt-Nr',
                    width: 100
                },{
                    dataIndex: 'CustomerNumber',
                    text: 'Kunden-Projekt-Nr',
                    width: 150
                },{
                    dataIndex: 'Languages',
                    text: 'Sprachen',
                    width: 100
                },{
                    dataIndex: 'Deadline',
                    text: 'Termin',
                    width: 100
                },{
                    dataIndex: 'Remark',
                    text: 'Bemerkungen',
                    width: 150,
                    hidden: true
                },{
                    dataIndex: 'Folder',
                    text: 'Ordner',
                    width: 100,
                    hidden: true
                }],
                bbar: Ext.create('Ext.PagingToolbar', {
                    pageSize: 25,
                    store: store,
                    displayInfo: true,
                    displayMsg: 'Zeige Projekte {0} - {1} von {2}',
                    emptyMsg: "Keine Projekte vorhanden",
                    
                }),
            },{
                xtype: 'form',
                title: 'Details',
                region: 'south',
                collapsible: true,
                height: 300,
            }]
        });
    })
    
    </script>
    When i put the total numbers inside the result array I get the total numbers but no data:
    Code:
    {
    "action":"GetData",
    "method":"getGrid",
    "result":{"total":"1371","result":[{"ID":"002e44de78df566708dd271250b9129b","Company":"...
    When I put the total numbers anywhere else I get the data but no total number.


    Please help.

    Thank you

    Bruno Rothbächer