ExtJS的读取JSON数据读不到 5
明明数据是正确的,但是为什么不显示呢这是Extjs代码varproxy=newExt.data.HttpProxy({url:'common/app/view/surve...
明明数据是正确的,但是为什么不显示呢
这是Extjs代码
var proxy=new Ext.data.HttpProxy( {url:'common/app/view/survey.json'});
//定义reader
var reader=new Ext.data.JsonReader(
{
},[
{name: 'appeId', mapping: 'appeId'},
{name: 'survId'},
{name: 'location'},
{name: 'surveyDate'},
{name: 'surveyTime'},
{name: 'inputUserId'}
]
)
//构建Store
var store=new Ext.data.Store( {
proxy:proxy
,reader:reader
});
//载入
store.load();
// create the grid
var grid = Ext.define('App.view.HomeData', {
extend : 'Ext.grid.GridPanel',
alias : 'widget.HomeData',
store: store,
columns: [
{header: "appeId", width: 60, dataIndex: 'appeId', sortable: true},
{header: "survId", width: 60, dataIndex: 'survId', sortable: true},
{header: "location", width: 60, dataIndex: 'location', sortable: true},
{header: "surveyDate", width: 100, dataIndex: 'surveyDate', sortable: true},
{header: "surveyTime", width: 100, dataIndex: 'surveyTime', sortable: true},
{header: "inputUserId", width:80, dataIndex: 'inputUserId', sortable: true}
],
width:1000,
height:400
});
还有JSON数据
[{"appeId":"1","survId":"1","location":"","surveyDate":"2008-03-14","surveyTime":"12:19:47","inputUserId":"1","inputTime":"2008-03-14 12:21:51","modifyTime":"0000-00-00 00:00:00"}] 展开
这是Extjs代码
var proxy=new Ext.data.HttpProxy( {url:'common/app/view/survey.json'});
//定义reader
var reader=new Ext.data.JsonReader(
{
},[
{name: 'appeId', mapping: 'appeId'},
{name: 'survId'},
{name: 'location'},
{name: 'surveyDate'},
{name: 'surveyTime'},
{name: 'inputUserId'}
]
)
//构建Store
var store=new Ext.data.Store( {
proxy:proxy
,reader:reader
});
//载入
store.load();
// create the grid
var grid = Ext.define('App.view.HomeData', {
extend : 'Ext.grid.GridPanel',
alias : 'widget.HomeData',
store: store,
columns: [
{header: "appeId", width: 60, dataIndex: 'appeId', sortable: true},
{header: "survId", width: 60, dataIndex: 'survId', sortable: true},
{header: "location", width: 60, dataIndex: 'location', sortable: true},
{header: "surveyDate", width: 100, dataIndex: 'surveyDate', sortable: true},
{header: "surveyTime", width: 100, dataIndex: 'surveyTime', sortable: true},
{header: "inputUserId", width:80, dataIndex: 'inputUserId', sortable: true}
],
width:1000,
height:400
});
还有JSON数据
[{"appeId":"1","survId":"1","location":"","surveyDate":"2008-03-14","surveyTime":"12:19:47","inputUserId":"1","inputTime":"2008-03-14 12:21:51","modifyTime":"0000-00-00 00:00:00"}] 展开
展开全部
第一、查看你的json是否正确
第二、我的写法,请参考
var itemsPerPage = 50;
var store = Ext.create('Ext.data.Store', {
autoLoad: { start: 0, limit: itemsPerPage },
fields: ['ZWWLDW_DWBH', 'ZWWLDW_DWMC', 'ZWWLDW_DWMM', 'ZWWLDW_DWQX', 'ZWWLDW_DWBZ'],
pageSize: itemsPerPage,
proxy: {
type: 'ajax',
url: 'HandlerFun.ashx?Type=CMManager',
reader: {
type: 'json',
root: 'rows',
totalProperty: 'total'
}
}
});
如果放我这个还不行,等一下,我把grid那里也发给你,这个都是项目中的
第二、我的写法,请参考
var itemsPerPage = 50;
var store = Ext.create('Ext.data.Store', {
autoLoad: { start: 0, limit: itemsPerPage },
fields: ['ZWWLDW_DWBH', 'ZWWLDW_DWMC', 'ZWWLDW_DWMM', 'ZWWLDW_DWQX', 'ZWWLDW_DWBZ'],
pageSize: itemsPerPage,
proxy: {
type: 'ajax',
url: 'HandlerFun.ashx?Type=CMManager',
reader: {
type: 'json',
root: 'rows',
totalProperty: 'total'
}
}
});
如果放我这个还不行,等一下,我把grid那里也发给你,这个都是项目中的
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询