2010-12-08 11 views
0

これをデバッグして解像度を取得する際に問題が発生します。ExtJS - エラー状態 'ProtoType'がヌルであるかオブジェクトではありません

データが正しく返されていますが、 'loadexception'関数にブレークポイントを設定すると、TypeErrorが捨てられます。ここでエラーです:

説明は - 「『プロトタイプ』はnullまたはオブジェクトではありません」 メッセージ - 「『プロトタイプ』はnullまたはオブジェクトではありません」 名 - 「例外TypeError」 数 - -2146823281

私のデータが正しく戻ってきても、私のコールボックスのメッセージボックスは常にエラーでスローされています。ここで

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

はあなたがリーダーオブジェクトを渡すJsonStore &を使用している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; 
    } 

応答(私はこれがあなたが求めているものだと思います)

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

答えて

1

ですjsonStoreはJsonReaderの設定を取得しますが&は読者自身を作成し​​ます。 JsonStore &へのごJsonReaderのExt.data.Store

  • V2020.dsPricing
  • のための移動のconfigsがJsonStoreを読者に合格しない

    1. 使用もう

    解決策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

    恐ろしいあなたは2の選択肢を持っています。説明をありがとうございます。私はそれが読者自身を作り出していたことに気付かなかった。 – PixelMuse

    関連する問題