Created
November 26, 2011 17:40
-
-
Save thorbenziemek/1396021 to your computer and use it in GitHub Desktop.
Ext.data.SingleRecordJsonReader demonstrates how to modify the Ext JS JsonReader (see http://thorben.ziemek.de/blog/2011/07/singlerecordjsonreader/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
root: [{ | |
field1:value1, | |
field2:value1 | |
},{ | |
field1:value2, | |
field2:value2 | |
}] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
root: { | |
field1:value1, | |
field2:value1 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.ns('Ext.data'); | |
Ext.data.SingleRecordJsonReader = Ext.extend(Ext.data.JsonReader, { | |
readRecords: function(data) { | |
var root = this.root; | |
data[root] = [data[root]]; | |
return Ext.data.SingleRecordJsonReader.superclass.readRecords.call(this, data); | |
} | |
}); | |
Ext.data.ReaderMgr.registerType('singlejson', Ext.data.SingleRecordJsonReader); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment