1. 对应gridpanel的store定义:
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
method: 'post',
url: ''
}),
reader: new Ext.data.JsonReader({
totalProperty : 'TOTALCOUNT',
root : 'ROOT'
}, [
'id', 'name', 'parentName', 'title'
])
//reader: new Ext.data.JsonReader({}, [
// 'id', 'name', 'parentName', 'title'
//])
});
如果返回的json数据没有分页信息,reader使用被注释的;
2. SimpleStore,常量store定义
new Ext.data.SimpleStore({
fields : ['name'],
data : [
['aaaa']
]
})
var searchStore = new Ext.data.ArrayStore({
fields: ['name'],
idIndex: 1
});
searchStore.removeAll();
searchStore.add(new Ext.data.Record({name: 'code2'}));
searchStore.add(new Ext.data.Record({name: 'code3'}));
searchStore.add(new Ext.data.Record({name: 'code4'}));
var rt = Ext.data.Record.create([
{name: 'fullname'},
{name: 'first'}
]);
var myStore = new Ext.data.Store({
reader: new Ext.data.ArrayReader(
{
idIndex: 0 // id for each record will be the first element
},
rt
)
});
var myData = [
[1, 'Fred Flintstone', 'Fred'], // note that id for the record is the first element
[2, 'Barney Rubble', 'Barney']
];
myStore.loadData(myData);
6. store通过Ext.data.XmlReader接收xml格式数据
var store= new Ext.data.Store({
url: '',
reader: new Ext.data.XmlReader({
totalProperty: 'total',
record: 'unit',
id: 'code2'
}, [{
name: 'code2', mapping: 'code2'
}, 'code3', 'code4'])
});
从后台返回的数据需要加上一句:
response.setContentType("text/xml; charset=UTF-8");