带外部URL的EXT JS Store [英] EXT JS Store with external URL
问题描述
嘿伙计们,
我正在建立一个带网格的EXT JS项目。它的商店定义如下:
createStore: function ( ){
var me = this ;
me.createDataModel();
var store = Ext.create( Ext.data.Store,{
model: tescoModel,
id: tescoStore,
autoLoad: true ,
remoteSort: true ,
pageSize: 20 ,
proxy:{
type: ajax,
url: http://www.techfortesco.com/groceryapi_b1/restservice.aspx ,
limitParam: undefined ,
startParam: undefined ,
simpleSortMode: true ,
pageParam: undefined ,
noCache: false ,
actionMethods:{
method: POST
},
reader:{
type: json,
root: Products,
totalProperty: TotalProductCount
}
}
});
但是这并没有返回任何g,它甚至不会连接到http://www.techfortesco.com ....
我相信extjs只允许连接到内部链接(例如/ techfortesco)。
extjs可以通过外部链接创建商店吗?我做错了吗?
谢谢
您需要将代理类型用作'jsonp'
createStore: function (){
var me = this ;
me.createDataModel();
var store = Ext.create( Ext.data.Store,{
model: tescoModel,
id: tescoStore,
autoLoad: true ,
remoteSort: true ,
pageSize: 20 ,
proxy:{
type: jsonp,
url: http://www.techfortesco.com/groceryapi_b1/restservice.aspx ,
limitParam: undefined ,
startParam: undefined ,
simpleSortMode: true ,
pageParam: undefined ,
noCache: false ,
actionMethods:{
method: POST
},
reader:{
type: json,
root: Products,
totalProperty: TotalProductCount
}
}
});
尝试EXTJS的Loader功能 -
装载机:{
url:'YourSourceUrl',
渲染器:'组件',
autoLoad :true
}
autoload:true,将在初始加载时自动加载数据。
Hey guys,
I'm building an EXT JS project with a grid. Its store is defined with the following:
createStore : function() {
var me = this;
me.createDataModel();
var store = Ext.create("Ext.data.Store", {
model : "tescoModel",
id : "tescoStore",
autoLoad : true,
remoteSort : true,
pageSize : 20,
proxy : {
type : "ajax",
url : "http://www.techfortesco.com/groceryapi_b1/restservice.aspx",
limitParam : undefined,
startParam : undefined,
simpleSortMode : true,
pageParam : undefined,
noCache : false,
actionMethods : {
method : "POST"
},
reader : {
type : "json",
root : "Products",
totalProperty : "TotalProductCount"
}
}
});
This however is not returning anything at all, it won't even make a connection to http://www.techfortesco.com....
I believe that extjs only allows to make connections to internal links (e.g. /techfortesco).
Is it possible for extjs to create a store from an external link? Am I doing something wrong?
Thanks
You need to use Proxy Type as 'jsonp'
createStore : function() { var me = this; me.createDataModel(); var store = Ext.create("Ext.data.Store", { model : "tescoModel", id : "tescoStore", autoLoad : true, remoteSort : true, pageSize : 20, proxy : { type : "jsonp", url : "http://www.techfortesco.com/groceryapi_b1/restservice.aspx", limitParam : undefined, startParam : undefined, simpleSortMode : true, pageParam : undefined, noCache : false, actionMethods : { method : "POST" }, reader : { type : "json", root : "Products", totalProperty : "TotalProductCount" } } });
Try Loader feature of EXTJS -
loader: { url: 'YourSourceUrl', renderer: 'component', autoLoad: true }
autoload: true, will load data automatically on initial loading.
这篇关于带外部URL的EXT JS Store的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!