PageRenderTime 23ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/srogerf/javascript
JavaScript | 47 lines | 10 code | 1 blank | 36 comment | 0 complexity | e69680c5b4923dc75e5744deba8dacb5 MD5 | raw file
  1. /**
  2. * @class Ext.data.JsonPStore
  3. * @extends Ext.data.Store
  4. * @private
  5. * <p>Small helper class to make creating {@link Ext.data.Store}s from different domain JSON data easier.
  6. * A JsonPStore will be automatically configured with a {@link Ext.data.reader.Json} and a {@link Ext.data.proxy.JsonP JsonPProxy}.</p>
  7. * <p>A store configuration would be something like:<pre><code>
  8. var store = new Ext.data.JsonPStore({
  9. // store configs
  10. autoDestroy: true,
  11. storeId: 'myStore',
  12. // proxy configs
  13. url: 'get-images.php',
  14. // reader configs
  15. root: 'images',
  16. idProperty: 'name',
  17. fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
  18. });
  19. * </code></pre></p>
  20. * <p>This store is configured to consume a returned object of the form:<pre><code>
  21. stcCallback({
  22. images: [
  23. {name: 'Image one', url:'/GetImage.php?id=1', size:46.5, lastmod: new Date(2007, 10, 29)},
  24. {name: 'Image Two', url:'/GetImage.php?id=2', size:43.2, lastmod: new Date(2007, 10, 30)}
  25. ]
  26. })
  27. * </code></pre>
  28. * <p>Where stcCallback is the callback name passed in the request to the remote domain. See {@link Ext.data.proxy.JsonP JsonPProxy}
  29. * for details of how this works.</p>
  30. * An object literal of this form could also be used as the {@link #cfg-data} config option.</p>
  31. * <p><b>*Note:</b> Although not listed here, this class accepts all of the configuration options of
  32. * <b>{@link Ext.data.reader.Json JsonReader}</b> and <b>{@link Ext.data.proxy.JsonP JsonPProxy}</b>.</p>
  33. * @xtype jsonpstore
  34. */
  35. Ext.define('Ext.data.JsonPStore', {
  36. extend: 'Ext.data.Store',
  37. alias : 'store.jsonp',
  38. constructor: function(config) {
  39. this.callParent(Ext.apply(config, {
  40. reader: new Ext.data.reader.Json(config),
  41. proxy : new Ext.data.proxy.JsonP(config)
  42. }));
  43. }
  44. });