1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    18
    Answers
    1
    Vote Rating
    0
    Cesium is on a distinguished road

      0  

    Default Answered: confusion with ajax proxies and data views

    Answered: confusion with ajax proxies and data views


    Hi, I am trying to set up a data view that displays information loaded into a store via an ajax proxy. right now I've got the ajax proxy set up to retreive information from a url that displays data in the following format:
    Code:
    [
    {
        "procgrp":"915rwp",
        "location":"nsaC1",
        "stats": [
            {"type":"Collection","time":1172730037,"cause":"Success","desc":"Successful collection"},  
            {"type":"Ingest","time":1302037721,"cause":"Success","desc":"Successful"}
        ]
    },
    {
        "procgrp":"915rwp",
        "location":"sgpC1",
        "stats": [
            {"type":"Collection","time":1172733136,"cause":"Success","desc":"Successful collection"},
            {"type":"Ingest","time":1302037958,"cause":"Success","desc":"Successful"}
        ]
    },
    // and so on
    ]
    My problem is that the dataview panel, which is supposed to display the 'procgrp' and 'location' of each data entry is completely empty, and I don't know why. Worse, I don't know how to go about figuring out why. What do I do to see if the Ajax proxy successfully reached the specified URL? To see if the reader successfully parsed the data? I'm really quite lost here, so any wisdom you can spare is greatly appreciated. Also, here's the relevant code:

    app.js:

    Code:
    Ext.Loader.setConfig({
        enabled: true
    });
    
    
    Ext.application({
        models: [
            'procfamGroup',
            'procfam'
        ],
        stores: [
            'grid'
        ],
        views: [
            'MainView',
            'FilterView'
        ],
        name: 'Dsview',
    
    
        launch: function() {
    
    
            Ext.create('Dsview.view.MainView', {fullscreen: true});
        }
    
    
    });
    view/MainView.js: (the relevant part)

    Code:
    Ext.define('Dsview.view.MainView', {
        extend: 'Ext.Panel',
    
    
        config: {
            items: [
                {
                    xtype: 'dataview',
                    itemTpl: [
                        '{procgrp}{location}'
                    ],
                    store: 'procfams'
                },
            ]
        },
    });
    store/grid.js:

    Code:
    Ext.define('Dsview.store.grid', {
        extend: 'Ext.data.Store',
        requires: [
            'Dsview.model.procfam'
        ],
    
    
        config: {
            autoLoad: true,
            model: 'Dsview.model.procfam',
            storeId: 'procfams',
            proxy: {
                type: 'ajax',
                url: 'datalist.php',
                reader: {
                    type: 'json'
                }
            }
        }
    });
    model/procfam.js

    Code:
    Ext.define('Dsview.model.procfam', {
        extend: 'Ext.data.Model',
        config: {
            fields: [
                {
                    name: 'procgrp',
                    type: 'string'
                },
                {
                    name: 'location',
                    type: 'string'
                },
                {
                    name: 'stats',
                    type: 'auto'
                }
            ]
        }
    });

  2. Hey everybody, I finally figured this out. The data was loading just fine, but for some reason the dataview wasn't being painted to the screen. I fixed this by changing the layout config of the MainView to 'fit'. Now it displays without issue.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,620
    Answers
    3452
    Vote Rating
    817
    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


    In your dataview, do you see some rows just blank or do you see not rows at all?

    If you load your store in the stores config of Ext.application (like you are doing) it will set the storeId and override the storeId config you set. Try changing the store config of the dataview to 'grid'
    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.

  4. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    18
    Answers
    1
    Vote Rating
    0
    Cesium is on a distinguished road

      0  

    Default


    Mitchellsimoens,

    Thanks for the comment. First, when I launch my application, the dataview panel appears totally empty. a light gray panel, just like nothing's there. Second, I changed the store config as you suggested and left the rest of the code alone, so it looks like this:

    Code:
                {
                    xtype: 'dataview',
    
    itemTpl: [ '{procgrp}, {location}' ],
    store: 'grid' },
    No visible change in the app, but it does give me this warning in chrome's JS console:
    [WARN][Ext.dataview.DataView#applyStore] The specified Store cannot be found
    EDIT- If it helps, I don't think it's making it as far as trying to use the model, because when I point the store to a model that completely does not fit the data being retrieved, nothing changes.

  5. #4
    Sencha User
    Join Date
    Mar 2012
    Posts
    18
    Answers
    1
    Vote Rating
    0
    Cesium is on a distinguished road

      0  

    Default


    Hey everybody, I finally figured this out. The data was loading just fine, but for some reason the dataview wasn't being painted to the screen. I fixed this by changing the layout config of the MainView to 'fit'. Now it displays without issue.

Thread Participants: 1