Question

I have:

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

I need php example for httpproxy create or update or destroy, i dont undestand how save all with php(send parameters?)?

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Was it helpful?

Solution

I do like this:

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

and it working.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top