2011-05-27 31 views
5

अपडेट नहीं करेगा किसी कारण से, ExtJS4 ग्रिड की यह कॉन्फ़िगरेशन अपडेट नहीं होगी। जब आप किसी सेल पर क्लिक करते हैं, तो मान बदलें, यह यूआरएल को हिट करता है, न कि प्रॉक्सी में परिभाषित अद्यतन यूआरएल, और एफएफ 4 में फायरबग के साथ मनाया जाता है। आश्चर्यजनक बात यह है कि डेटा शुरू होने पर स्टोर लोड करने के बाद डेटाचांग घटना आग लगती है, लेकिन डेटा वास्तव में बदलने के बाद नहीं। इसके अलावा, ग्रिड बनाने के लिए सभी पंक्तियां भेजें।ExtJS4 ग्रिड दूरस्थ डेटाबेस

क्या कोई मुझे बता सकता है कि मैं क्या गलत कर रहा हूं?

Ext.onReady(function() { 

    Ext.BLANK_IMAGE_URL = '/images/extjs4/s.gif'; 
    Ext.tip.QuickTipManager.init(); 
    //Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider')); 

    Ext.define('VendorError', { 
     extend: 'Ext.data.Model', 
     fields: [ 
      {name: 'UnexpSrvID', type: 'int'}, 
      {name: 'VendorID', type: 'int'}, 
      {name: 'VendorName', type: 'string'}, 
      {name: 'VndActID', type: 'int'}, 
      {name: 'VndActNb', type: 'string'}, 
      {name: 'InvoiceID', type: 'int'}, 
      {name: 'VInvNb', type: 'string'}, 
      {name: 'VInvRcptDt', type: 'date', dateFormat: 'Y-m-d' }, 
      {name: 'InvDate', type: 'date', dateFormat: 'Y-m-d' }, 
      {name: 'CodeSpecifier', type: 'string'}, 
      {name: 'Recurrence', type: 'string'}, 
      {name: 'ClientID', type: 'int'}, 
      {name: 'ClientName', type: 'string'}, 
      {name: 'LocID', type: 'int'}, 
      {name: 'LocName', type: 'string'}, 
      {name: 'RecentLocStatus', type: 'string'}, 
      {name: 'RecentLocStatusDate', type: 'date', dateFormat: 'Y-m-d' }, 
      {name: 'UnexpCost', type: 'float'}, 
      {name: 'ConfirmedAmt', type: 'float'}, 
      {name: 'StaffID', type: 'int'}, 
      {name: 'NetworkID', type: 'string'}, 
      {name: 'UnexpStatCode', type: 'string'} 
     ], 
     proxy: { 
      type: 'ajax', 
      simpleSortMode: true, 
      api: { 
       read: '/internal/viewVERext_json.asp', 
       create: '/internal/viewVERext_create.asp', 
       update: '/internal/viewVERext_update.asp', 
       destroy: '/internal/viewVERext_destroy.asp' 
      }, 
      reader: { 
       type: 'json', 
       totalProperty: 'total', 
       successProperty: 'success', 
       messageProperty: 'message', 
       root: 'data' 
      }, 
      writer: { 
       type: 'json', 
       writeAllFields: false, 
       allowSingle: false, 
       root: 'data' 
      }, 
      listeners: { 
       exception: function(proxy, response, operation){ 
        Ext.MessageBox.show({ 
         title: 'REMOTE EXCEPTION', 
         msg: operation.getError(), 
         icon: Ext.MessageBox.ERROR, 
         buttons: Ext.Msg.OK 
        }); 
       } 
      } 
     } 
    }); 

    var store = Ext.create('Ext.data.Store', { 
     model: 'VendorError', 
     autoLoad: true, 
     autoSync: true, 
     pageSize: 20, 
     remoteSort: true, 
     listeners: { 
     // write: function(proxy, operation){ 
     //  if (operation.action == 'destroy') { 
     //   main.child('#form').setActiveRecord(null); 
     //  } 
     //  Ext.example.msg(operation.action, operation.resultSet.message); 
     // } 
      datachanged: function() { 
       var report = ""; 
       store.each( 
        function(rec) { 
         report = report + rec.dirty + '/'; 
        } 
       ) 
       alert(report); 
      } 
     } 
    }); 

    // create the Grid 
    var grid = Ext.create('Ext.grid.Panel', { 
     store: store, 
     //stateful: true, 
     //stateId: 'stateGrid', 
     columns: [ 
      { text  : 'Vendor', 
       dataIndex: 'VendorName', 
       flex  : 1 
      }, 
      { text  : 'Account', 
       dataIndex: 'VndActNb' 
      }, 
      { text  : 'Invoice', 
       dataIndex: 'VInvNb' 
      }, 
      { text  : 'Invoiced', 
       dataIndex: 'InvDate', 
       xtype : 'datecolumn', 
       align : 'center' 
      }, 
      { text  : 'Receipted', 
       dataIndex: 'VInvRcptDt', 
       xtype : 'datecolumn', 
       align : 'center' 
      }, 
      { text  : 'Description', 
       dataIndex: 'CodeSpecifier' 
      }, 
      { text  : 'Client', 
       dataIndex: 'ClientName' 
      }, 
      { text  : 'Location', 
       dataIndex: 'LocName' 
      }, 
      { text  : 'LStatus', 
       dataIndex: 'RecentLocStatus', 
       align : 'center' 
      }, 
      { text  : 'Credit', 
       dataIndex: 'UnexpCost', 
       tdCls : 'colyellow', 
       renderer : Ext.util.Format.usMoney, 
       align : 'right', 
       field : { xtype:'textfield', allowBlank:false } 
      }, 
      { text  : 'Confirmed', 
       dataIndex: 'ConfirmedAmt', 
       tdCls : 'colyellow', 
       renderer : Ext.util.Format.usMoney, 
       align : 'right', 
       field : { xtype:'textfield', allowBlank:false } 
      }, 
      { text  : 'Recurrence', 
       dataIndex: 'Recurrence', 
       tdCls : 'colyellow', 
       align : 'center', 
       field : { 
        xtype : 'combobox', 
        typeAhead: true, 
        triggerAction: 'all', 
        selectOnTab: true, 
        store: [ 
         ['once','once'],['1st','1st'],['2nd+','2nd+'] 
        ], 
        lazyRender: true 
       } 
      }, 
      { text  : 'CStatus', 
       dataIndex: 'UnexpStatCode', 
       tdCls : 'colyellow', 
       align : 'center', 
       field : { 
        xtype : 'combobox', 
        typeAhead: true, 
        triggerAction: 'all', 
        selectOnTab: true, 
        store: [ 
         <%=cstat_grid%> 
        ], 
        lazyRender: true 
       } 
      }, 
      { text  : 'Owner', 
       dataIndex: 'NetworkID', 
       tdCls : 'colyellow', 
       field : { 
        xtype : 'combobox', 
        typeAhead: true, 
        triggerAction: 'all', 
        selectOnTab: true, 
        store: [ 
         <%=staff_grid%> 
        ], 
        lazyRender: true 
       } 
      } 
     ], 
     layout: 'fit', 
     height: 500, 
     renderTo: 'theGrid', 
     selType: 'cellmodel', 
     plugins: [ 
      Ext.create('Ext.grid.plugin.CellEditing', { 
       clicksToEdit: 1 
      }) 
     ], 
     dockedItems: [ 
      { xtype: 'pagingtoolbar', 
       store: store, 
       dock: 'bottom', 
       displayInfo: true 
      }, 
      { xtype: 'toolbar', 
       dock: 'top', 
       items: [ 
        { xtype:'button', 
         text: 'IsDirty()', 
         handler: function() { 
         var report = ""; 
         store.each( 
          function(rec) { 
           report = report + rec.dirty + '/'; 
          } 
         ) 
         alert(report); 
         } 
        } 
       ] 
      } 
     ], 
     viewConfig: { 
      stripeRows: true 
     } 
    }); 

    Ext.EventManager.onWindowResize(grid.doLayout, grid); 
}); 

उत्तर

2

बाहर कर देता है मुद्दा है कि ग्रिड में जोड़ा रिकॉर्ड के रूप में "कोई नई बात नहीं" में एक विशिष्ट आईडी फ़ील्ड का मान द्वारा पता लगाया जाता है। सेन्चा मंचों पर एक प्रकार poster ने मुझे इसकी ओर इशारा किया।

डिफ़ॉल्ट रूप से, मॉडल में इस फ़ील्ड को 'आईडी' का नाम होने की उम्मीद है। इसलिए, आपको या तो 'आईडी' के क्षेत्र के साथ एक मॉडल प्रदान करना होगा, जिस पर ऊपर मेरे मॉडल के पास नहीं था, या आपको Ext.data.Model की idProperty प्रॉपर्टी का उपयोग कर डिफ़ॉल्ट कॉलम को ओवरराइड करना होगा। मैंने बस UnexpSrvId कॉलम का नाम बदलकर id कर दिया। और, देखो और देखें, हम बनाने() के बजाय अद्यतन() को अपडेट भेजते हैं।

यह एपीआई दस्तावेज़ों से स्पष्ट नहीं है, दुर्भाग्य से इस शक्तिशाली ढांचे में कई चीजें हैं।

0

अपने ग्रिड CellEdit mixin उपयोग कर रहा है क्योंकि आप grid जो संपादन के बाद अपने रिकॉर्ड के लिए परिवर्तन हो जाएंगे करने के लिए एक श्रोता जोड़ सकते हैं। अपने ग्रिड में तो, जोड़ने श्रोताओं config विकल्प इस प्रकार के रूप में परिभाषित ...

listeners: { 
    edit : function(e) { 
     e.record.commit(); 
    } 
} 

संपादित करें: मुझे लगता है आप अपनी प्रॉक्सी पर गलत सिंटैक्स का उपयोग कर रहे हैं ... आप केवल द्वारा एक पाठक और लेखक परिभाषित कर सकते हैं (चीजों के दिखता है) ...

Ed Spencer's article on Proxies

ExtJS 4 API Entry on Proxies

+0

"चूंकि आपका ग्रिड सेलएडिट मिक्सीन का उपयोग कर रहा है" तो, प्लगइन परिणामों का उपयोग प्रॉक्सी पर बनाने (अपडेट के बजाए) को चलाने और उसे सभी पंक्तियों को भेजने के लिए एक सेल में अपडेट में किया जा रहा है? यह बहुत गलत लगता है। साथ ही, मुद्दा यह नहीं है कि सर्वर पर कुछ भी नहीं है, बल्कि यह कि सभी 20 पंक्तियां यूआरएल बनाने के लिए भेजी जाती हैं! – alphadogg

+0

मैं अभी अपनी मशीन पर एक्स्टजेस 4 डाउनलोड कर रहा हूं, मेरे पास एक खेल होगा क्योंकि मुझे विश्वास नहीं है कि यह जवाब है ... माफ़ी माफ़ी अगर – JamesHalsall

+1

कोई समस्या नहीं है! आपका समय सबसे सराहना की है। – alphadogg

संबंधित मुद्दे