我有:
var writer = new Ext.data.JsonWriter({
encode: true,
writeAllFields: false
});
var reader = new Ext.data.JsonReader({
idProperty: 'id',
root: 'data',
}, [
{name: 'id'},
{name: 'status'},
{name: 'login'},
{name: 'fio'},
{name: 'description'},
{name: 'create_date'}
]);
var proxy = new Ext.data.HttpProxy({
api: {
read : '/test/read.php',
create : '/test/create.php',
update : '/test/update.php',
destroy : '/test/destroy.php'
}
});
var store = new Ext.data.Store({
proxy: proxy,
reader: reader,
writer: writer,
autoLoad: true,
autoSave: false
});
我需要php示例为httpproxy创建或更新或销毁,我不知道怎么用php保存所有(发送参数?)?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
答案 0 :(得分:0)
我喜欢这个:
proxy.on('beforewrite', function(proxy, action, rec) {
if (action=='update') {
if (!rec.length) {
var record = new Array(rec);
}else{
var record = rec;
}
for (var i=0; i<record.length; i++) //>
{
xmlhttp.open('GET', '/test/dtp_users.php?level=1&id='+record[i].get('id')+'&status='+record[i].get('status')+'&login='+record[i].get('login')+'&fio='+record[i].get('fio')+'&description='+record[i].get$
xmlhttp.send(null);
if(xmlhttp.status == 200) {
Ext.Msg.alert('Статус сохранения',xmlhttp.responseText);
};
};
};
if (action=='destroy') {
if (!rec.length) {
var record = new Array(rec);
}else{
var record = rec;
}
for (var i=0; i<record.length; i++) //>
{
xmlhttp.open('GET', '/test/dtp_users.php?level=2&id='+record[i].get('id')+'&status='+record[i].get('status')+'&login='+record[i].get('login')+'&fio='+record[i].get('fio')+'&description='+record[i].get$
xmlhttp.send(null);
if(xmlhttp.status == 200) {
Ext.Msg.alert('Статус сохранения',xmlhttp.responseText);
};
};
};
if (action=='create') {
if (!rec.length) {
var record = new Array(rec);
}else{
var record = rec;
}
for (var i=0; i<record.length; i++) //>
{
xmlhttp.open('GET', '/test/dtp_users.php?level=3&id='+record[i].get('id')+'&status='+record[i].get('status')+'&login='+record[i].get('login')+'&fio='+record[i].get('fio')+'&description='+record[i].get$
xmlhttp.send(null);
if(xmlhttp.status == 200) {
Ext.Msg.alert('Статус сохранения',xmlhttp.responseText);
};
};
};
});
它正在运作。