1. #1
    Sencha User luisparada's Avatar
    Join Date
    Nov 2007
    Location
    Venezuela
    Posts
    94
    Answers
    2
    Vote Rating
    2
    luisparada is on a distinguished road

      0  

    Default Unanswered: Issue loading records through jsonP proxy

    Unanswered: Issue loading records through jsonP proxy


    I have a jsonp proxy that retrieve records from another domain, somehow the grid is not adding the records I get. I tested using a the respond I get from the domain locally and the grid works perfectly but when changing to jsonp it doesn't append all records inside the grid
    this is the data store:
    Code:
    Ext.define('MooReports.store.stats.PlacementStats',{
        storeId:'placementstats-store-id',
        extend: 'Ext.data.Store',
        model:'MooReports.model.stats.PlacementStats',
        proxy: {
            type: 'jsonp',
            url : 'http://moo.myurl.net/json.php',
            extraParams:{
                api:'statsReportPlacements',
                date:'120512'
            },
            reader: {
                type: 'json'
            }
        },
        autoLoad:true,
        groupField:'PubName',
        sorters: {property: 'ROI', direction: 'DESC'},
    });
    This is the repond I get, and I actually see that the url respond correctly with the json structure, I can see the result using firebug of course.
    Code:
    [{"PlcmntName":"728x90 - ROS & ATF","Clk":85,"Conversions":1,"PubName":"TheDailySheeple.com","PubId":33,"Date":"2012-12-05","Spend":288,"Imp":17296,"Revenue":35.08,"SubId":"","PlcmntId":71},{"PlcmntName":"728x90 - ROS & BTF","Clk":93,"Conversions":0,"PubName":"HenryMakow.com","PubId":34,"Date":"2012-12-05","Spend":240,"Imp":34428,"Revenue":0,"SubId":"","PlcmntId":73},{"PlcmntName":"300x250 - ROS & ATF Survival","Clk":151,"Conversions":3,"PubName":"GunShows-USA.com","PubId":36,"Date":"2012-12-05","Spend":204,"Imp":11422,"Revenue":105.24,"SubId":"","PlcmntId":75},{"PlcmntName":"728x90 - ATF & Home Page","Clk":1,"Conversions":0,"PubName":"WorldThreats.com","PubId":37,"Date":"2012-12-05","Spend":40,"Imp":1,"Revenue":0,"SubId":"","PlcmntId":76},{"PlcmntName":"300x250 - ROS & ATF Energy","Clk":122,"Conversions":2,"PubName":"GunShows-USA.com","PubId":36,"Date":"2012-12-05","Spend":204,"Imp":11165,"Revenue":36,"SubId":"","PlcmntId":78},{"PlcmntName":"300x250 - ROS & SP","Clk":0,"Conversions":0,"PubName":"BeforeItsNews.com","PubId":38,"Date":"2012-12-05","Spend":0,"Imp":1,"Revenue":0,"SubId":"","PlcmntId":79},{"PlcmntName":"728x90 - ROS & Above The Fold","Clk":660,"Conversions":4,"PubName":"WND.com","PubId":42,"Date":"2012-12-05","Spend":338.38,"Imp":150390,"Revenue":129.22,"SubId":"","PlcmntId":82},{"PlcmntName":"300x250 - ROS & ATF","Clk":0,"Conversions":0,"PubName":"WND.com","PubId":42,"Date":"2012-12-05","Spend":0,"Imp":3,"Revenue":0,"SubId":"","PlcmntId":83},{"PlcmntName":"300x250 - ROS & Energy","Clk":0,"Conversions":0,"PubName":"MichaelSavage.com","PubId":44,"Date":"2012-12-05","Spend":0,"Imp":6,"Revenue":0,"SubId":"","PlcmntId":87},{"PlcmntName":"300x250 - ROS & Survival","Clk":1,"Conversions":0,"PubName":"MichaelSavage.com","PubId":44,"Date":"2012-12-05","Spend":0,"Imp":6,"Revenue":0,"SubId":"","PlcmntId":88},{"PlcmntName":"300x250 - ROS & ATF","Clk":0,"Conversions":0,"PubName":"PersonalLiberty.com","PubId":48,"Date":"2012-12-05","Spend":0.01,"Imp":1,"Revenue":0,"SubId":"","PlcmntId":92},{"PlcmntName":"300x250 - ROS & ATF","Clk":0,"Conversions":0,"PubName":"PrisonPlanet.com","PubId":51,"Date":"2012-12-05","Spend":0,"Imp":1,"Revenue":0,"SubId":"","PlcmntId":96},{"PlcmntName":"728x90 - ROS","Clk":1,"Conversions":0,"PubName":"FishingClub.com","PubId":53,"Date":"2012-12-05","Spend":0,"Imp":0,"Revenue":0,"SubId":"","PlcmntId":101},{"PlcmntName":"728x90 - ROS","Clk":8,"Conversions":0,"PubName":"CAPoliticalNews.com","PubId":54,"Date":"2012-12-05","Spend":4.48,"Imp":2230,"Revenue":0,"SubId":"","PlcmntId":103},{"PlcmntName":"300x250 - ROS","Clk":0,"Conversions":0,"PubName":"ChristianResponseAlerts.com","PubId":55,"Date":"2012-12-05","Spend":70,"Imp":82,"Revenue":0,"SubId":"","PlcmntId":104},{"PlcmntName":"300x250 - ROS & ATF","Clk":67,"Conversions":2,"PubName":"ConservativeActionAlerts.com","PubId":56,"Date":"2012-12-05","Spend":6.15,"Imp":3071,"Revenue":70.16,"SubId":"","PlcmntId":105},{"PlcmntName":"728x90 - ROS & ATF","Clk":16,"Conversions":1,"PubName":"ConservativeByte.com","PubId":57,"Date":"2012-12-05","Spend":24.84,"Imp":9038,"Revenue":35.08,"SubId":"","PlcmntId":106},{"PlcmntName":"250x250 - ROS & ATF","Clk":0,"Conversions":0,"PubName":"OffTheGridNews.com","PubId":58,"Date":"2012-12-05","Spend":175,"Imp":6,"Revenue":0,"SubId":"","PlcmntId":107},{"PlcmntName":"300x250 - ROS & ATF","Clk":1,"Conversions":0,"PubName":"BreitBart.com","PubId":61,"Date":"2012-12-05","Spend":0.03,"Imp":20,"Revenue":0,"SubId":"","PlcmntId":110},{"PlcmntName":"728x90 - ROS","Clk":1,"Conversions":0,"PubName":"PatriotUpdate.com","PubId":45,"Date":"2012-12-05","Spend":0,"Imp":2,"Revenue":0,"SubId":"","PlcmntId":112},{"PlcmntName":"468x60 - ROS & ATF","Clk":72,"Conversions":0,"PubName":"LewRockwell.com","PubId":63,"Date":"2012-12-05","Spend":21.92,"Imp":21904,"Revenue":0,"SubId":"","PlcmntId":113},{"PlcmntName":"300x250 - ROS & ATF @ $2.25","Clk":4388,"Conversions":78,"PubName":"WND.com","PubId":42,"Date":"2012-12-05","Spend":1012.69,"Imp":450086,"Revenue":2671.34,"SubId":"","PlcmntId":114},{"PlcmntName":"160x600 - SP @ $2.25","Clk":3594,"Conversions":43,"PubName":"WND.com","PubId":42,"Date":"2012-12-05","Spend":453.83,"Imp":201706,"Revenue":1445.54,"SubId":"","PlcmntId":115},{"PlcmntName":"300x250","Clk":0,"Conversions":0,"PubName":"J Carter Marketing","PubId":64,"Date":"2012-12-05","Spend":0,"Imp":2,"Revenue":0,"SubId":"","PlcmntId":116},{"PlcmntName":"300x250 - ATF","Clk":2,"Conversions":0,"PubName":"TheBlaze.com","PubId":62,"Date":"2012-12-05","Spend":0.11,"Imp":12,"Revenue":0,"SubId":"","PlcmntId":119},{"PlcmntName":"728x90 - ROS & ATF","Clk":1,"Conversions":0,"PubName":"TheBlaze.com","PubId":62,"Date":"2012-12-05","Spend":0,"Imp":6,"Revenue":0,"SubId":"","PlcmntId":121},{"PlcmntName":"300x250 - ROS & BTF","Clk":2644,"Conversions":42,"PubName":"InfoWars.com","PubId":49,"Date":"2012-12-05","Spend":364.02,"Imp":364020,"Revenue":1380.86,"SubId":"","PlcmntId":125},{"PlcmntName":"620x100 - Home Page","Clk":1687,"Conversions":20,"PubName":"InfoWars.com","PubId":49,"Date":"2012-12-05","Spend":262.13,"Imp":121922,"Revenue":635,"SubId":"","PlcmntId":126},{"PlcmntName":"300x250 - ROS & BTF","Clk":340,"Conversions":2,"PubName":"PrisonPlanet.com","PubId":51,"Date":"2012-12-05","Spend":75.73,"Imp":50488,"Revenue":70.16,"SubId":"","PlcmntId":127},{"PlcmntName":"620x100 - Home Page","Clk":236,"Conversions":3,"PubName":"PrisonPlanet.com","PubId":51,"Date":"2012-12-05","Spend":99.01,"Imp":46054,"Revenue":94.14,"SubId":"","PlcmntId":128},{"PlcmntName":"728x90 - ROS & ATF","Clk":71,"Conversions":0,"PubName":"PakalertPress.com","PubId":66,"Date":"2012-12-05","Spend":1190,"Imp":16450,"Revenue":0,"SubId":"","PlcmntId":129},{"PlcmntName":"550x100 - ATF & Home Page","Clk":131,"Conversions":0,"PubName":"WhatReallyHappened.com","PubId":73,"Date":"2012-12-05","Spend":960,"Imp":45972,"Revenue":0,"SubId":"","PlcmntId":142},{"PlcmntName":"300x250 - ATF & ROS @ $1.25","Clk":1250,"Conversions":26,"PubName":"BreitBart.com","PubId":61,"Date":"2012-12-05","Spend":258.09,"Imp":206443,"Revenue":849.18,"SubId":"","PlcmntId":143},{"PlcmntName":"300x250 - ROS","Clk":1150,"Conversions":7,"PubName":"MichaelSavage.com","PubId":44,"Date":"2012-12-05","Spend":137.3,"Imp":68651,"Revenue":245.56,"SubId":"","PlcmntId":144},{"PlcmntName":"160x600","Clk":0,"Conversions":0,"PubName":"DrudgeReport.com","PubId":40,"Date":"2012-12-05","Spend":0,"Imp":4,"Revenue":0,"SubId":"","PlcmntId":147},{"PlcmntName":"300x250 - Top","Clk":0,"Conversions":0,"PubName":"DrudgeReport.com","PubId":40,"Date":"2012-12-05","Spend":0,"Imp":3,"Revenue":0,"SubId":"","PlcmntId":148},{"PlcmntName":"728x90","Clk":0,"Conversions":0,"PubName":"DrudgeReport.com","PubId":40,"Date":"2012-12-05","Spend":0,"Imp":5,"Revenue":0,"SubId":"","PlcmntId":149},{"PlcmntName":"300x250 - BTF & ROS","Clk":364,"Conversions":0,"PubName":"VigilantCitizen.com","PubId":75,"Date":"2012-12-05","Spend":816,"Imp":53431,"Revenue":0,"SubId":"","PlcmntId":153},{"PlcmntName":"300x250 ","Clk":120,"Conversions":2,"PubName":"TownHall.com","PubId":47,"Date":"2012-12-05","Spend":88.09,"Imp":58715,"Revenue":59.06,"SubId":"","PlcmntId":154},{"PlcmntName":"728x90","Clk":183,"Conversions":6,"PubName":"TownHall.com","PubId":47,"Date":"2012-12-05","Spend":153.5,"Imp":102343,"Revenue":214.18,"SubId":"","PlcmntId":155},{"PlcmntName":"300x250 - Left","Clk":0,"Conversions":0,"PubName":"DrudgeReport.com","PubId":40,"Date":"2012-12-05","Spend":0,"Imp":3,"Revenue":0,"SubId":"","PlcmntId":157},{"PlcmntName":"300x250 - Right","Clk":0,"Conversions":0,"PubName":"DrudgeReport.com","PubId":40,"Date":"2012-12-05","Spend":0,"Imp":3,"Revenue":0,"SubId":"","PlcmntId":158},{"PlcmntName":"300x600","Clk":188,"Conversions":0,"PubName":"TownHall.com","PubId":47,"Date":"2012-12-05","Spend":86.55,"Imp":57706,"Revenue":0,"SubId":"","PlcmntId":159},{"PlcmntName":"612x100 - Home Page ATF","Clk":53,"Conversions":0,"PubName":"TheIntelHub.com","PubId":77,"Date":"2012-12-05","Spend":840,"Imp":5323,"Revenue":0,"SubId":"","PlcmntId":160},{"PlcmntName":"468x60 - Header","Clk":70,"Conversions":0,"PubName":"VeteransToday.com","PubId":78,"Date":"2012-12-05","Spend":0,"Imp":63400,"Revenue":0,"SubId":"","PlcmntId":161},{"PlcmntName":"468x60 - Article","Clk":29,"Conversions":0,"PubName":"VeteransToday.com","PubId":78,"Date":"2012-12-05","Spend":0,"Imp":45009,"Revenue":0,"SubId":"","PlcmntId":162},{"PlcmntName":"300x250 - ROS","Clk":728,"Conversions":23,"PubName":"NewsMax.com","PubId":43,"Date":"2012-12-05","Spend":367.25,"Imp":73440,"Revenue":740.24,"SubId":"","PlcmntId":167},{"PlcmntName":"300x250","Clk":3,"Conversions":0,"PubName":"Yahoo.com","PubId":79,"Date":"2012-12-05","Spend":0,"Imp":9,"Revenue":0,"SubId":"","PlcmntId":171},{"PlcmntName":"160x600","Clk":1,"Conversions":0,"PubName":"Yahoo.com","PubId":79,"Date":"2012-12-05","Spend":0,"Imp":5,"Revenue":0,"SubId":"","PlcmntId":172},{"PlcmntName":"728x90","Clk":0,"Conversions":0,"PubName":"Yahoo.com","PubId":79,"Date":"2012-12-05","Spend":0,"Imp":6,"Revenue":0,"SubId":"","PlcmntId":173},{"PlcmntName":"300x100","Clk":1,"Conversions":0,"PubName":"Yahoo.com","PubId":79,"Date":"2012-12-05","Spend":0,"Imp":5,"Revenue":0,"SubId":"","PlcmntId":174},{"PlcmntName":"160x180","Clk":0,"Conversions":0,"PubName":"Yahoo.com","PubId":79,"Date":"2012-12-05","Spend":0,"Imp":1,"Revenue":0,"SubId":"","PlcmntId":175},{"PlcmntName":"160x600","Clk":50,"Conversions":1,"PubName":"WhitePages.com","PubId":80,"Date":"2012-12-05","Spend":85.11,"Imp":46001,"Revenue":35.08,"SubId":"","PlcmntId":176},{"PlcmntName":"300x250","Clk":60,"Conversions":0,"PubName":"WhitePages.com","PubId":80,"Date":"2012-12-05","Spend":72.22,"Imp":39040,"Revenue":0,"SubId":"","PlcmntId":177},{"PlcmntName":"728x90","Clk":44,"Conversions":0,"PubName":"WhitePages.com","PubId":80,"Date":"2012-12-05","Spend":99.81,"Imp":57038,"Revenue":0,"SubId":"","PlcmntId":178},{"PlcmntName":"300x600 - ROS & ATF","Clk":208,"Conversions":2,"PubName":"WND.com","PubId":42,"Date":"2012-12-05","Spend":78.74,"Imp":22496,"Revenue":59.06,"SubId":"","PlcmntId":179},{"PlcmntName":"300x250 - BTF & ROS @ 1.80","Clk":56,"Conversions":0,"PubName":"WND.com","PubId":42,"Date":"2012-12-05","Spend":25.49,"Imp":14162,"Revenue":0,"SubId":"","PlcmntId":180},{"PlcmntName":"300x250 - BTF & ROS","Clk":142,"Conversions":0,"PubName":"PakalertPress.com","PubId":66,"Date":"2012-12-05","Spend":210,"Imp":16067,"Revenue":0,"SubId":"","PlcmntId":181},{"PlcmntName":"180x160","Clk":0,"Conversions":0,"PubName":"Yahoo.com","PubId":79,"Date":"2012-12-05","Spend":0.01,"Imp":17,"Revenue":0,"SubId":"","PlcmntId":182},{"PlcmntName":"300x250","Clk":136,"Conversions":0,"PubName":"RawStory.com","PubId":81,"Date":"2012-12-05","Spend":86.46,"Imp":86438,"Revenue":0,"SubId":"","PlcmntId":183},{"PlcmntName":"Wonkette.com","Clk":29,"Conversions":0,"PubName":"Wonkette.com","PubId":82,"Date":"2012-12-05","Spend":10.17,"Imp":10170,"Revenue":0,"SubId":"","PlcmntId":184}]
    this is the model:
    Code:
    Ext.define('MooReports.model.stats.PlacementStats', {
        extend: 'Ext.data.Model',
        fields:[
                {name: 'PlcmntName', 	type: 'string'},
                {name: 'PubId', 			type: 'number'},
                {name: 'PubName', 		type: 'string'},
                {name: 'Date',          type:'string'},
                {name: 'PlcmntId', 		type: 'number'},
                {name: 'Imp', 				type: 'int', sortType: 'asInt'},
                {name: 'Clk', 				type: 'int', sortType: 'asInt'},
                {name: 'Spend', 			type: 'float', sortType: 'asFloat'},
                {name: 'Revenue', 		type: 'float', sortType: 'asFloat'},
                {name: 'Conversions', 	type: 'int'},
                {name: 'pCPM', 	type: 'float', sortType: 'asFloat'},
                {name: 'ROI', convert: convROI, sortType: 'asFloat', type: 'float'}
        ]
    });
    and this is the grid:
    Code:
    Ext.define('MooReports.view.stats.PlacementStats' ,{
        extend: 'Ext.grid.Panel',
        alias : 'widget.placementsstats',
    
        title:'Placement Stats',
        autoWidth:true,
        autoHeight:true,
        initComponent: function() {
            /*var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
                groupHeaderTpl: 'Empresa: {name} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})'
            });*/
            
            var times = Ext.create('Ext.data.Store', {
                fields: ['value', 'title'],
                data : [
                    {"value":"TOD", "title":"Today"},
                    {"value":"YES", "title":"Yesterday"},
                    {"value":"LW", "title":"Last Week"},
                    {"value":"LM", "title":"Last Month"}
                ]
            });
            
            this.id = 'placementstats-gridpanel';
            
            this.frame = true;
            
            this.closable = false;
            
            this.store = 'stats.PlacementStats';
            
            this.viewConfig = {
                stripeRows: false
            };
            
            //this.features = [groupingFeature];
            
            this.columns = [
                { header: 'Placement', dataIndex: 'PlcmntId', flex:1, hidden:true},
                { header: 'Placement', dataIndex: 'PlcmntName', width:250 },
                { header: 'Impressions', dataIndex: 'Imp', flex: 1, renderer: Ext.util.Format.numberRenderer('0,000'), summaryType: 'sum',
                    summaryRenderer: Ext.util.Format.numberRenderer('0,000')
                },
                {header: 'Date', dataIndex: 'Date', flex: 1},
                { header: 'Clicks', dataIndex: 'Clk', flex: 1, renderer: Ext.util.Format.numberRenderer('0,000'), summaryType: 'sum',
                    summaryRenderer: Ext.util.Format.numberRenderer('0,000')
                },
                { header: 'CTR', renderer: calcCTR, flex: 1, hidden: true},
                { header: 'Spend', dataIndex: 'Spend', flex: 1, renderer: Ext.util.Format.usMoney, summaryType: 'sum',
                    summaryRenderer: Ext.util.Format.numberRenderer('$0,000.00'),
                },
                { header: 'Revenue',	dataIndex: 'Revenue', flex: 1, renderer: Ext.util.Format.usMoney, summaryType: 'sum',
                    summaryRenderer: Ext.util.Format.numberRenderer('$0,000.00'),
                },
                { header: 'Cost', renderer: calcCPM, flex: 1, hidden: true },
                { header: 'eCPM', renderer: calcECPM, flex: 1, hidden: true },
                { header: 'Conv', dataIndex: 'Conversions', width: 40},
                { header: 'eCPA', renderer: calcECPA, width: 50},
                { header: 'EPC', renderer: calcEPC, flex: 1, hidden: true },
                { header: 'CPC', renderer: calcCPC, flex: 1, hidden: true },
                { header: 'Profit', renderer: calcProfit, width: 70, summaryType: 'sum',
                    summaryRenderer: Ext.util.Format.numberRenderer('$0,000.00')
                },
                { header: 'ROI', renderer: calcROI, flex: 1, dataIndex: 'ROI', sortable: true },
                { header: 'pCPM', renderer: calcCPM, flex: 1, dataIndex: 'ROI', sortable: true, hidden:true },
                { header: 'ROI % Change', dataIndex: '', flex: 1, hidden: true}
            ];
            
            this.bbar = Ext.create('Ext.PagingToolbar', {
                store: 'stats.PlacementStats',
                displayInfo: true,
                displayMsg: 'Displaying {0} - {1} of {2}',
                emptyMsg: "No records to show"
            });
            
            this.features = [{
                id: 'group',
                groupHeaderTpl: '{name}',
                hideGroupedHeader: true,
                ftype: 'groupingsummary'
            }]
            
            this.tbar = [
            {
                text:'Expand +',
                action:'expand'
            },'->',
            {
                xtype:'combo',
                labelWidth:50,
                fieldLabel: 'Range',
                store: times,
                queryMode: 'local',
                displayField: 'title',
                valueField: 'value'
            },{
                xtype: 'fieldcontainer',
                layout: 'hbox',
                defaultType: 'textfield',
                defaults: {
                    labelWidth:25,
                    margins: '0 0 0 6',
                    flex:1
                },
                items:[{
                    xtype: 'datefield',
                    width:150,
                    name:'startdate',
                    fieldLabel: 'Start',
                    maxValue: new Date(),
                    allowBlank:false
                },{
                    xtype: 'datefield',
                    width:150,
                    name:'enddate',
                    fieldLabel: 'End',
                    maxValue: new Date(),
                    allowBlank:false
                }]
            },{
                text:'Update',
                iconCls:'update',
                action:'update'
            }];
            
            this.callParent(arguments);
        }
    });
    ____________________________________
    do not make install, just compile it.!!!
    --------------------------------------------------
    //*************k4m1k4z3************\\

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,142
    Answers
    3504
    Vote Rating
    855
    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 JSON you provided, is that 100% what you send back? If so, that is not valid JsonP response, you need a callback function around it based on the callback param in the request.

    In PHP:

    Code:
    if (isset($_REQUEST['callback'])) {
        header('Content-Type: application/javascript');
        echo $_REQUEST['callback'] . '(';
    }
    
    echo json_encode($someArr);
    
    if (isset($_REQUEST['callback'])) {
        echo ');';
    }
    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.

Thread Participants: 1

Tags for this Thread