2014-01-17 51 views
1

我:如何用Ext.data.HttpProxy保存更改?

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 
    }); 

我需要HTTPPROXY PHP例如創建,更新或毀滅,我不如何已瞭解所有保存用php(發送參數?)?

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

回答

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); 
           }; 
           }; 
    }; 
    }); 

和它的工作。