PageRenderTime 51ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/ext-4.1.0_b3/src/data/JsonStore.js

https://bitbucket.org/srogerf/javascript
JavaScript | 62 lines | 15 code | 3 blank | 44 comment | 1 complexity | 51bee5e8d80169385488a8832268021f MD5 | raw file
  1. /**
  2. * @author Ed Spencer
  3. * @class Ext.data.JsonStore
  4. * @ignore
  5. *
  6. * <p>Small helper class to make creating {@link Ext.data.Store}s from JSON data easier.
  7. * A JsonStore will be automatically configured with a {@link Ext.data.reader.Json}.</p>
  8. *
  9. * <p>A store configuration would be something like:</p>
  10. *
  11. <pre><code>
  12. var store = new Ext.data.JsonStore({
  13. // store configs
  14. autoDestroy: true,
  15. storeId: 'myStore',
  16. proxy: {
  17. type: 'ajax',
  18. url: 'get-images.php',
  19. reader: {
  20. type: 'json',
  21. root: 'images',
  22. idProperty: 'name'
  23. }
  24. },
  25. //alternatively, a {@link Ext.data.Model} name can be given (see {@link Ext.data.Store} for an example)
  26. fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
  27. });
  28. </code></pre>
  29. *
  30. * <p>This store is configured to consume a returned object of the form:<pre><code>
  31. {
  32. images: [
  33. {name: 'Image one', url:'/GetImage.php?id=1', size:46.5, lastmod: new Date(2007, 10, 29)},
  34. {name: 'Image Two', url:'/GetImage.php?id=2', size:43.2, lastmod: new Date(2007, 10, 30)}
  35. ]
  36. }
  37. </code></pre>
  38. *
  39. * <p>An object literal of this form could also be used as the {@link #cfg-data} config option.</p>
  40. *
  41. * @xtype jsonstore
  42. */
  43. Ext.define('Ext.data.JsonStore', {
  44. extend: 'Ext.data.Store',
  45. alias: 'store.json',
  46. constructor: function(config) {
  47. config = config || {};
  48. Ext.applyIf(config, {
  49. proxy: {
  50. type : 'ajax',
  51. reader: 'json',
  52. writer: 'json'
  53. }
  54. });
  55. this.callParent([config]);
  56. }
  57. });