JsonPStore.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-data-JsonPStore'>/**
  19. </span> * @class Ext.data.JsonPStore
  20. * @extends Ext.data.Store
  21. * &lt;p&gt;Small helper class to make creating {@link Ext.data.Store}s from different domain JSON data easier.
  22. * A JsonPStore will be automatically configured with a {@link Ext.data.reader.Json} and a {@link Ext.data.proxy.JsonP JsonPProxy}.&lt;/p&gt;
  23. * &lt;p&gt;A store configuration would be something like:&lt;pre&gt;&lt;code&gt;
  24. var store = new Ext.data.JsonPStore({
  25. // store configs
  26. storeId: 'myStore',
  27. // proxy configs
  28. url: 'get-images.php',
  29. // reader configs
  30. root: 'images',
  31. idProperty: 'name',
  32. fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
  33. });
  34. * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  35. * &lt;p&gt;This store is configured to consume a returned object of the form:&lt;pre&gt;&lt;code&gt;
  36. stcCallback({
  37. images: [
  38. {name: 'Image one', url:'/GetImage.php?id=1', size:46.5, lastmod: new Date(2007, 10, 29)},
  39. {name: 'Image Two', url:'/GetImage.php?id=2', size:43.2, lastmod: new Date(2007, 10, 30)}
  40. ]
  41. })
  42. * &lt;/code&gt;&lt;/pre&gt;
  43. * &lt;p&gt;Where stcCallback is the callback name passed in the request to the remote domain. See {@link Ext.data.proxy.JsonP JsonPProxy}
  44. * for details of how this works.&lt;/p&gt;
  45. * An object literal of this form could also be used as the {@link #cfg-data} config option.&lt;/p&gt;
  46. * @xtype jsonpstore
  47. */
  48. Ext.define('Ext.data.JsonPStore', {
  49. extend: 'Ext.data.Store',
  50. alias : 'store.jsonp',
  51. requires: [
  52. 'Ext.data.proxy.JsonP',
  53. 'Ext.data.reader.Json'
  54. ],
  55. constructor: function(config) {
  56. config = Ext.apply({
  57. proxy: {
  58. type: 'jsonp',
  59. reader: 'json'
  60. }
  61. }, config);
  62. this.callParent([config]);
  63. }
  64. });</pre>
  65. </body>
  66. </html>