2010-12-08 8 views
0

J'ai quelques problèmes pour le déboguer et obtenir une résolution.ExtJS - Etats d'erreur 'ProtoType' est nul ou pas un objet

Mes données me sont retournées correctement, mais elles me jettent le TypeError quand je place un point d'arrêt sur la fonction 'loadexception'. Voici l'erreur:

Description - "prototype» est nul ou non un objet" message - " 'prototype' est nul ou non un objet" nom - "TypeError" Numéro - -2146823281

Donc, même si mes données sont correctes, mon message de boîte d'appel est toujours jeté sur l'erreur.

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

Voici le code JsonReader

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

La réponse (je pense que c'est ce que vous demandez)

{"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}]}} 

Répondre

1

vous utilisez JsonStore & passer un objet lecteur mais jsonStore obtient la config d'un JsonReader & crée un lecteur lui-même. vous avez 2 choix:

  1. utilisation Ext.data.Store pour V2020.dsPricing
  2. déplacer configs de votre JsonReader à JsonStore & ne passe pas le lecteur à la solution JsonStore plus

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

Impressionnant . Merci pour la clarification. Je n'ai pas réalisé que c'était créer un lecteur lui-même. – PixelMuse