0
votes

I am looking for some blog or example for YQL explaining with MVC architecture. I feel difficult in understanding kitchen sink example. Can any one share simple MVC on YQL. so it will be helpful for other also.

1

1 Answers

3
votes

I don't know about YQL, but based on the link user3849047 provided it's basically a request against some remote api. So integration might be a little bit more tricky than in this draft.

Basically, this is how it should work.

You will get some kind of data from the api calls. This data can be represented as an Ext.data.Model. A bunch of models is organized and stored in Ext.data.Store.

So all you have to do is populating the store somehow. There are two ways.

Do it in your controller:

Ext.create("Controller", {
    extend: "Ext.app.Controller",

    getStoreData: function () {
        var me = this;
        Ext.data.JsonP.request({
            url: "yqlRequestUrl",
            params: {
                // request parameter
            },
            success: function ( result, request ) {
                me.fillStore( result );
            }
        });
    },

    fillStore: function ( result ) {
        var data = transformResultIntoModels( result );
        var store = Ext.getStore("myStore");
        store.add( data );
    }
});

You execute the api request and the transformation of the response into the models all by yourself.

Or let your store do it for you:

Ext.define("MyStore", {
    extend: "Ext.data.Store",

    autoLoad: false,
    storeId: "mystore",
    model: "MyModel",
    proxy: {
        type: "jsonP",
        url: "yqlRequestUrl",
        extraParams: {
            // request parameter
        },
        reader: {
            type: "json",
            rootProperty: "yourRootElement"
        }
    }
});

Since this store is set to autoLoad: false you have to load the store manually by

store.load({ 
    callback: function ( records, operation, success ) {
    },
    scope: this
});