Results 1 to 2 of 2

Thread: [4.0.7] metaData is not read in wrapped JSON (ASP.NET)

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-5677 in 4.1.2.
  1. #1
    Sencha User
    Join Date
    Sep 2011
    Vote Rating

    Default [4.0.7] metaData is not read in wrapped JSON (ASP.NET)

    ASP.NET tends to wrap JSON responses with a "d" property e.g.

        "metaData": {
            "root": "data",
            "fields": [{
                "type": "int",
                "name": "id",
                "hidden": true,
                "header": "id",
                "groupable": false,
                "dataIndex": "id"
            }, ...omitted for brevity...]
        "success": true,
        "data": [{
            "id": "1",
            "controller": "Permissions",
            "description": "Allow to see permission by roles",
            "administrator": true,
            "marketing": false
    Unfortunately there is no simple way around this. There is a reason behind the madness (I believe it's to do with a specific JS injection attack). So we ASP.NET devs try to live with it.

    This is normally not an issue with EXTJS as one can set the root of the data in the proxy's reader of the store. However this does not apply to reading the metaData of a JSON response.

    The reason is that the method 'readRecords' does not check if the metaData exists on a lower nested level (it is assumed the metaData exists on the top level of the response). So for example when trying to reconfigure a grid's columns the metaData is never read, so a bunch of rows will appear but the actual data will not.

    A working solution is to use the 'getRoot()' function of the Reader to always get the defined root of the data. Here's my override:
    Ext.override(, {
        readRecords: function (data) {
            //this has to be before the call to super because we use the meta data in the superclass readRecords
            if (this.getRoot(data).metaData) {
            * @deprecated will be removed in Ext JS 5.0. This is just a copy of this.rawData - use that instead
            * @property {Object} jsonData
            this.jsonData = data;
            return this.callParent([data]);
    Hope this helps

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Gainesville, FL
    Vote Rating


    Sounds reasonable. Just a little optimization on your code, I would put this.getRoot(data) onto a variable so you don't have to do the execution twice.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts