1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    8
    Vote Rating
    0
    chenzhaoplus is on a distinguished road

      0  

    Default Answered: How can i loaddata in store from a url?

    Answered: How can i loaddata in store from a url?


    my code is:
    Code:
            Ext.Ajax.request({
                    url : 'http://localhost:8080/admin-web/jsonservice/foodEmbranchmentService.json',
                    method : 'POST',
                    jsonData : {
                        jsonrpc : "2.0",
                        id : 10,
                        method : "findAll"
                    },
                    success : function(result, request) {
                        var resultStr = result.responseText;
                        var jsonObj = Ext.decode(resultStr);
                        var jsonStr = Ext.encode(jsonObj);
                        store.loadData(jsonObj.result.resultList);
                    },
                    failure : function(form, action) {
                        Ext.MessageBox.alert("JSON Test", "JSON Failed´╝ü");
                    }
                });
    Code:
    Ext.define('MyApp.stores.CanyindanweiStore', {
        extend : 'Ext.data.Store',
        singleton : true,
        requires : ['MyApp.models.CanyindanweiModel'],
    
    
        model : 'MyApp.models.CanyindanweiModel',
        remoteSort : false,
        storeId : 'canyindanweiStore'
    });
    i don't use proxy but Ext.ajax.requst in store because proxy can not post jsonData to url.If i loaddata in store,the data can show in gridpanel,the problem is when i select a record,i can not get a record from selectionmodel.

  2. Why don't you use ajax proxy with extraParams config.
    Code:
    Ext.define('MyApp.stores.CanyindanweiStore', {
        extend : 'Ext.data.Store',
        singleton : true,
        requires : ['MyApp.models.CanyindanweiModel'],
        model : 'MyApp.models.CanyindanweiModel',
        remoteSort : false,
        storeId : 'canyindanweiStore',
        proxy: {
            type: 'ajax',
            url: 'http://localhost:8080/admin-web/jsonservice/foodEmbranchmentService.json',
            method: 'POST',
            extraParams: {
                jsonrpc : "2.0",
                id : 10,
                method : "findAll"
            },
            reader: {
                type: 'json',
                root: 'root'
            }
        }
    });

  3. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Vote Rating
    114
    Answers
    346
    vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold

      0  

    Default


    Why don't you use ajax proxy with extraParams config.
    Code:
    Ext.define('MyApp.stores.CanyindanweiStore', {
        extend : 'Ext.data.Store',
        singleton : true,
        requires : ['MyApp.models.CanyindanweiModel'],
        model : 'MyApp.models.CanyindanweiModel',
        remoteSort : false,
        storeId : 'canyindanweiStore',
        proxy: {
            type: 'ajax',
            url: 'http://localhost:8080/admin-web/jsonservice/foodEmbranchmentService.json',
            method: 'POST',
            extraParams: {
                jsonrpc : "2.0",
                id : 10,
                method : "findAll"
            },
            reader: {
                type: 'json',
                root: 'root'
            }
        }
    });

  4. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    8
    Vote Rating
    0
    chenzhaoplus is on a distinguished road

      0  

    Default


    i tried,it doesn't work. i just checked my code.i find my problem is i spelled the wrong name in formpanel.so i can't see the data in formpanel.the problem is cleared. thank you!

Thread Participants: 1

Tags for this Thread