PDA

View Full Version : ?????????????



ak_ext
14 Apr 2009, 3:47 AM
ext?grid?????????????????
????????????????

??????????????????????

??????????httpProxy??????
var firstGridStore = new Ext.data.Store({
//root: 'data',
//totalProperty: 'totalProperty',
id: 'index',
remoteSort: true,
proxy: new Ext.data.HttpProxy({url: "/sample/app?U=U_SEARCH", method: "GET"}),
reader: reader
});

???
firstGridStore.load({params:{start:0, limit:10}});
?1???????????????????

???start?limit????????????
??????????SQL?start?limit??????????????
??????????????????????????????
???????????????????
????????????10??????10????????????
???????????????????
1???????ajax???????????????????????

yuki
14 Apr 2009, 4:02 AM
??????????httpProxy??????
var firstGridStore = new Ext.data.Store({
//root: 'data',
//totalProperty: 'totalProperty',
id: 'index',
remoteSort: true,
proxy: new Ext.data.HttpProxy({url: "/sample/app?U=U_SEARCH", method: "GET"}),
reader: reader
});


totalProperty???????????

ak_ext2
14 Apr 2009, 7:12 AM
???totalProperty?ext????
?????????????????????????????
root?totalProperty???????????
??????????????????

json???????????????????????????
{'totalProperty':120,'data':{[data1:'aaa',data2:'bbb'],[data1:'ccc',data2:'ddd']...}}
???

yuki
14 Apr 2009, 11:03 AM
{'totalProperty':120,'data':{[data1:'aaa',data2:'bbb'],[data1:'ccc',data2:'ddd']...}}

?
?

{'totalProperty':120,'data':[{data1:'aaa',data2:'bbb'},{data1:'ccc',data2:'ddd'}...]}
????????????????

ak_ext2
14 Apr 2009, 3:32 PM
????????????
{'totalProperty':120,'data':[{data1:'aaa',data2:'bbb'},{data1:'ccc',data2:'ddd'}...]}
???
????????????????""???????
????''???????????????????????????
????
totalProperty ?root???????????????????

yuki
14 Apr 2009, 4:08 PM
?????????????????????????????

????????????Firebug???????????????????????????


Store????????????????Store?id?????????Ext.StoreMgr.lookup????????
??????????????HttpProxy???load?loadResponse??????????????????????
loadResponse???????????request????????????????
loadexception??????????????
loadResponse???reader?????response??????????


??????????????????????????????????

?????????????????response?reader??????????????????????????HttpProxy.loadResponse??????????????????????????????????????????????????


try {
result = o.reader.read(response);
}catch(e){
...

ak_ext
15 Apr 2009, 9:39 PM
id??????Ext.StoreMgr.lookup?????????????????????
????reader????????????????

??store?getTotalCount()??????0????
??????????????????????????
?????????????

?????store.data??????????
????????????????????????

ak_ext
15 Apr 2009, 10:46 PM
ext-all.js?readRecords ?
s.totalProperty??????????????????
this.jsonData = o???????????????
????var s = this.meta?mata??????????
???filed??????????totalProperty????????
?????????????????????

store????????????????
var firstGridStore = new Ext.data.Store({
root: 'data',
totalProperty: 'totalProperty',???
id: 'index',
remoteSort: true,
proxy: new Ext.data.HttpProxy({url: "/sample/app?U=U_SEARCH", method: "GET"}),
reader: reader
});

readRecords : function(o){


this.jsonData = o;
if(o.metaData){
delete this.ef;
this.meta = o.metaData;
this.recordType = Ext.data.Record.create(o.metaData.fields);
this.onMetaChange(this.meta, this.recordType, o);
}
var s = this.meta, Record = this.recordType,
f = Record.prototype.fields, fi = f.items, fl = f.length;
// Generate extraction functions for the totalProperty, the root, the id, and for each field
if (!this.ef) {
if(s.totalProperty) {
this.getTotal = this.getJsonAccessor(s.totalProperty);
}
if(s.successProperty) {
this.getSuccess = this.getJsonAccessor(s.successProperty);
}
this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
if (s.id) {
var g = this.getJsonAccessor(s.id);
this.getId = function(rec) {
var r = g(rec);
return (r === undefined || r === "") ? null : r;
};
} else {
this.getId = function(){return null;};
}
this.ef = [];
for(var i = 0; i < fl; i++){
f = fi[i];
var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
this.ef[i] = this.getJsonAccessor(map);
}
}
var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
if(s.totalProperty){
var v = parseInt(this.getTotal(o), 10);
if(!isNaN(v)){
totalRecords = v;
}
}

ak_ext
15 Apr 2009, 11:29 PM
????????????????????