开发者

ExtJS - Error states 'ProtoType' is null or not an object

I'm having some troubles debugging this and getting a resolution.

My data is being returned to me correctly, but it's throwing out the TypeError at me when I put a break point on the 'loadexception' function. Here is the error:

description - "'prototype' is null or not an object" message - "'prototype' is null or not an object" name - "TypeError" number - -2146823281

So even though my data is coming back right, my callbox message box is always getting thrown on the error.

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

    V20开发者_开发技巧20.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
            });
        }
    });

Here is the 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;
    }

The response (I think this is what you are asking for)

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


you're using JsonStore & passing a reader object to it but jsonStore gets config of a JsonReader & creates a reader itself. you have 2 choices:

  1. use Ext.data.Store for V2020.dsPricing
  2. move configs of your JsonReader to JsonStore & don't pass reader to JsonStore anymore

solution 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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜