2012-11-02 4 views
0

안녕하세요 모두 제가 직접 셀 예제를 사용하여 작은 데이터를 업데이트 섹션에서 일하고 있습니다. 나는 셀 플러그인을 사용하여 데이터를 업데이트 할 수 없다, 나는 할 수있다. 삭제 및 db 직접 업데이트가 있지만 기존 필드를 편집 할 때 화면에 오류 및 업데이트가 표시되지 않고 네트워크 영역이나 네트워크의 콘솔에 POST 응답이 표시되지 않는 이유는 무엇입니까? 여기 extjs4 그리드 업데이트 옵션을 사용하여 MySQL에서 데이터를 업데이트하는 방법

Ext.onReady(function() { 
    Ext.direct.Manager.addProvider(Ext.app.REMOTING_API); 

    //added model inside onready 
    Ext.define('PersonalInfo', { 
     extend: 'Ext.data.Model', 
     fields: ['id', 'name', 'address', 'state','st_one','st_two','st_three','st_for'] 
    }); 

    //separated store into unique var for guaranteeRange 
    var store = Ext.create('Ext.data.Store', { 
     id: 'store', 
     model: 'PersonalInfo', 
     autoLoad: true, 
     proxy: { 
      type: 'direct', 
      api: { 
       create:QueryDatabase.createRecord, 
       read:QueryDatabase.getResults, 
       update:QueryDatabase.updateRecords, 
       destroy:QueryDatabase.destroyRecord 
      } 
     } 
    }); 

    var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { 
     clicksToMoveEditor: 1, 
     autoCancel: false 

    }); 


    var alphaSpaceTest = /^[-\sa-zA-Z]+$/; 

    Ext.apply(Ext.form.field.VTypes, { 
     // vtype validation function 
     alphaSpace: function(val, field) { 
      return alphaSpaceTest.test(val); 
     }, 
     // vtype Text property: The error text to display when the validation function returns false 
     alphaSpaceText: 'Not a valid state. Must not contain numbers.', 
     // vtype Mask property: The keystroke filter mask 
     alphaSpaceMask: /^[-\sa-zA-Z]+$/ 
    }); 

    // create the Grid 
    var grid = Ext.create('Ext.grid.Panel', { 
     //height: 550, 
     //width: 800, 
     cls: 'grid', 
     title: 'Production Planning Control', 
     store: store, 
     columns: [{ 
      dataIndex: 'id', 
      width: 50, 
      text: 'ID' 
     }, { 
      dataIndex: 'name', 
      flex: 0.5, 
      text: 'ClientName', 
      //pt 2 
      allowBlank: false, 
      field: { 
       type: 'textfield', 
       allowBlank: false 
      } 
     }, { 
      dataIndex: 'address', 
      flex: 0.5, 
      text: 'Product Name', 
      //pt 2 
      allowBlank: false, 
      field: { 
       type: 'textfield', 
       allowBlank: false 
      } 
     }, { 
      dataIndex: 'state', 
      flex: 0.8, 
      text: 'No Of QtyRequired', 
      //pt 2 
      allowBlank: false, 
      field: { 
       type: 'textfield', 
       allowBlank: false, 
       //vtype: 'alphaSpace' 
      } 
     },{ 
      dataIndex: 'st_one', 
      flex: 0.7, 
      text: 'Station 1', 
      //pt 2 
      allowBlank: false, 
      field: { 
       type: 'textfield', 
       //allowBlank: false, 
       //vtype: 'alphaSpace' 
      } 
}, 
      { 
      dataIndex: 'st_two', 
      flex: 0.7, 
      text: 'Station 2', 
      //pt 2 
      allowBlank: false, 
      field: { 
       type: 'textfield', 
       //allowBlank: false, 
       //vtype: 'alphaSpace' 
      } 
     },{ 
      dataIndex: 'st_three', 
      flex: 0.7, 
      text: 'Station 3', 
      //pt 2 
      allowBlank: false, 
      field: { 
       type: 'textfield', 
       //allowBlank: false, 
       //vtype: 'alphaSpace' 
      } 
     }, 
      { 
      dataIndex: 'st_for', 
      flex: 0.7, 
      text: 'Station 4', 
      //pt 2 
      allowBlank: false, 
      field: { 
       type: 'textfield', 
       //allowBlank: false, 
       //vtype: 'alphaSpace' 
      } 
     } 

     ], 
     renderTo: Ext.getBody(), 
     //pt 2 
     plugins: [ 
      rowEditing 
     ], 
     dockedItems: [{ 
      xtype: 'toolbar', 
      store: store, 
      dock: 'bottom', 
      //creating, add items 
      items: [{ 
       iconCls: 'add', 
       text: 'Add', 
       handler: function() { 
        rowEditing.cancelEdit(); 
        // create a record 
        var newRecord = Ext.create('PersonalInfo'); 
        store.insert(0, newRecord); 
        rowEditing.startEdit(0, 0); 

        // write about this section in tutorial 
        var sm = grid.getSelectionModel(); 
        grid.on('edit', function() { 

         var record = sm.getSelection(); 
         store.record.commit(); 
         //store.sync(); 
         //e.record.commit(); 
         //store.commitChanges(); 
         store.remove(record); 
         store.load(); 
         store.sync(); 
         alert ('dome'); 




        }); 
       } 
      }, { 
       iconCls: 'delete', 
       text: 'Delete', 
       handler: function() { 
        rowEditing.cancelEdit(); 
        var sm = grid.getSelectionModel(); 
        Ext.Msg.show({ 
         title:'Delete Record?', 
         msg: 'You are deleting a record permanently, this cannot be undone. Proceed?', 
         buttons: Ext.Msg.YESNO, 
         icon: Ext.Msg.QUESTION, 
         fn: function(btn){ 
          if(btn === 'yes') { 
           store.remove(sm.getSelection()); 
           store.sync(); 
          } 
         } 
        }); 
       } 
      }, 
      { 
       xtype: 'button', 
       iconCls:'refresh', 
       text: 'Refresh Grid', 
      // action: 'refresh', 
       handler:function(){ 
        //var reload=this.getGridPanel().getStore(); 
        store.load(); 
       } 

      }] 
     }] 
    }); 
}); 

답변

0

당신은 그냥 자동으로 게시하도록 autoSync:true 저장 설정을 사용할 수 있습니다 도와주세요 코드입니다. 우리가 `code`var rowEditing = Ext.create ('Ext.grid.plugin.RowEditing'@dbrin 여기처럼 사용해야 할

+0

그러나, { \t \t clicksToMoveEditor : 1, \t \t AUTOCANCEL : 거짓, \t \t autoSync : true \t}); –

+0

autoSync는 저장소 속성입니다. – dbrin

+0

가게에서 맡겨주세요 !! –

관련 문제