SequentialIdGenerator.html 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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-SequentialIdGenerator'>/**
  19. </span> * @author Don Griffin
  20. *
  21. * This class is a sequential id generator. A simple use of this class would be like so:
  22. *
  23. * Ext.define('MyApp.data.MyModel', {
  24. * extend: 'Ext.data.Model',
  25. * idgen: 'sequential'
  26. * });
  27. * // assign id's of 1, 2, 3, etc.
  28. *
  29. * An example of a configured generator would be:
  30. *
  31. * Ext.define('MyApp.data.MyModel', {
  32. * extend: 'Ext.data.Model',
  33. * idgen: {
  34. * type: 'sequential',
  35. * prefix: 'ID_',
  36. * seed: 1000
  37. * }
  38. * });
  39. * // assign id's of ID_1000, ID_1001, ID_1002, etc.
  40. *
  41. */
  42. Ext.define('Ext.data.SequentialIdGenerator', {
  43. extend: 'Ext.data.IdGenerator',
  44. alias: 'idgen.sequential',
  45. constructor: function() {
  46. var me = this;
  47. me.callParent(arguments);
  48. me.parts = [ me.prefix, ''];
  49. },
  50. <span id='Ext-data-SequentialIdGenerator-cfg-prefix'> /**
  51. </span> * @cfg {String} prefix
  52. * The string to place in front of the sequential number for each generated id. The
  53. * default is blank.
  54. */
  55. prefix: '',
  56. <span id='Ext-data-SequentialIdGenerator-cfg-seed'> /**
  57. </span> * @cfg {Number} seed
  58. * The number at which to start generating sequential id's. The default is 1.
  59. */
  60. seed: 1,
  61. <span id='Ext-data-SequentialIdGenerator-method-generate'> /**
  62. </span> * Generates and returns the next id.
  63. * @return {String} The next id.
  64. */
  65. generate: function () {
  66. var me = this,
  67. parts = me.parts;
  68. parts[1] = me.seed++;
  69. return parts.join('');
  70. }
  71. });
  72. </pre>
  73. </body>
  74. </html>