-
29 Mar 2012 5:45 PM #1
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!"); } });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.Code:Ext.define('MyApp.stores.CanyindanweiStore', { extend : 'Ext.data.Store', singleton : true, requires : ['MyApp.models.CanyindanweiModel'], model : 'MyApp.models.CanyindanweiModel', remoteSort : false, storeId : 'canyindanweiStore' });
-
Best Answer Posted by vietits
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' } } });
-
29 Mar 2012 6:26 PM #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' } } });
-
29 Mar 2012 6:33 PM #3
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!


Reply With Quote