2010-12-08 15 views
0

Ich habe einige Probleme, dies zu debuggen und eine Lösung zu bekommen.ExtJS - Fehlerzustände 'ProtoType' ist null oder kein Objekt

Meine Daten werden korrekt an mich zurückgesendet, aber es wirft den TypeError auf mich, wenn ich einen Unterbrechungspunkt auf die "Loadexception" -Funktion setze. Hier ist der Fehler:

Beschreibung - „‚Prototyp‘ist Null oder kein Objekt“ Nachricht - „‚Prototyp‘ist Null oder kein Objekt“ Namen - „Typeerror“ Nummer - -2146823281

Also, obwohl meine Daten wieder richtig sind, wird mein Callbox-Meldungsfeld immer auf den Fehler geworfen.

V2020.dsPricing = new Ext.data.JsonStore({ 
     proxy: new Ext.data.HttpProxy({ 
     method: 'POST', 
     url: url, 
     headers: {"Content-Type": "application/json; charset=utf-8"}, 
     jsonData: Ext.util.JSON.encode({ serviceId: objPricingReturn.serviceId }) 
     }), 
     reader: PricingJsonReader() 
    });  

    V2020.dsPricing.on('loadexception', function(obj, options, response, err) { 
     Ext.MessageBox.show({ 
      title: 'Error', 
      msg: url + ' POST method fail...ErrorCode:' + response.status, 
      buttons: Ext.MessageBox.OK, 
      icon: Ext.MessageBox.ERROR 
     }); 
    }); 

    V2020.dsPricing.load({ 
     callback: function(records, o, s) { 
      if (!s) Ext.MessageBox.show({ 
       title: 'Error', 
       msg: ' Failed to load pricing data', 
       buttons: Ext.MessageBox.OK, 
       icon: Ext.MessageBox.ERROR 
      }); 
     } 
    }); 

Hier ist der JsonReader Code

function PricingJsonReader() { 
     var pricingReaderObject = new Ext.data.JsonReader({ 
      root: 'GetServicePriceByIdResult.ServicePricing', 
      fields: [{ 
       name: 'priceId', 
       type: 'int' 
      }, 
     { 
      name: 'serviceId', 
      type: 'int' 
     }, 
     { 
      name: 'price', 
      type: 'float' 
     }, 
     { 
      name: 'startDate', 
      type: 'date', 
      dateFormat: 'n/j/Y' 
     }, 
     { 
      name: 'endDate', 
      type: 'date', 
      dateFormat: 'n/j/Y' 
     }, 
     { 
      name: 'updatedBy', 
      type: 'string' 
     }, 
     { 
      name: 'updateDate', 
      type: 'date', 
      dateFormat: 'n/j/Y' 
     }] 
     }) 
     return pricingReaderObject; 
    } 

Die Antwort (Ich denke, das ist das, was Sie fordern)

{"GetServicePriceByIdResult":{"ServicePricing":[{"priceId":14,"serviceId":1,"price":70.0000,"startDate":"6\/14\/2010 12:00:00 AM","endDate":"12\/31\/2011 12:00:00 AM","updatedBy":null,"updateDate":null},{"priceId":142,"serviceId":1,"price":70.0000,"startDate":"6\/14\/2010 12:00:00 AM","endDate":"12\/31\/2011 12:00:00 AM","updatedBy":null,"updateDate":null}]}} 

Antwort

1

Sie verwenden JsonStore & Führen eines Leser-Objekt es aber jsonStore bekommt Konfiguration eines JsonReader & erstellt einen Leser selbst. Sie haben 2 Möglichkeiten:

  1. Verwendung Ext.data.Store für V2020.dsPricing
  2. bewegen configs Ihrer JsonReader zu JsonStore & nicht Leser JsonStore passieren mehr

Lösung 1:

 
var url = "http://localhost/r.json"; 
objPricingReturn = {serviceId:10}; 

function PricingJsonReader() { 
     var pricingReaderObject = new Ext.data.JsonReader({ 
      root: 'GetServicePriceByIdResult.ServicePricing', 
      fields: [{ 
       name: 'priceId', 
       type: 'int' 
      }, 
     { 
      name: 'serviceId', 
      type: 'int' 
     }, 
     { 
      name: 'price', 
      type: 'float' 
     }, 
     { 
      name: 'startDate', 
      type: 'date', 
      dateFormat: 'n/j/Y' 
     }, 
     { 
      name: 'endDate', 
      type: 'date', 
      dateFormat: 'n/j/Y' 
     }, 
     { 
      name: 'updatedBy', 
      type: 'string' 
     }, 
     { 
      name: 'updateDate', 
      type: 'date', 
      dateFormat: 'n/j/Y' 
     }] 
     }) 
     return pricingReaderObject; 
    } 


V2020 = {}; 
V2020.dsPricing = new Ext.data.Store({ 
     proxy: new Ext.data.HttpProxy({ 
     method: 'POST', 
     url: url, 
     headers: {"Content-Type": "application/json; charset=utf-8"}, 
     jsonData: Ext.util.JSON.encode({ serviceId: objPricingReturn.serviceId }) 
     }), 
     reader: PricingJsonReader() 
    });  

    V2020.dsPricing.on('loadexception', function(obj, options, response, err) { 
     Ext.MessageBox.show({ 
      title: 'Error', 
      msg: url + ' POST method fail...ErrorCode:' + response.status, 
      buttons: Ext.MessageBox.OK, 
      icon: Ext.MessageBox.ERROR 
     }); 
    }); 

    V2020.dsPricing.load({ 
     callback: function(records, o, s) { 
      if (!s) Ext.MessageBox.show({ 
       title: 'Error', 
       msg: ' Failed to load pricing data', 
       buttons: Ext.MessageBox.OK, 
       icon: Ext.MessageBox.ERROR 
      }); 
     } 
    }); 
+0

Ehrfürchtig . Danke für die Abklärung. Ich wusste nicht, dass es selbst einen Leser schafft. – PixelMuse

Verwandte Themen