PageSizePlugin.js 1002 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. Ext.namespace('Ext.ux');
  2. Ext.ux.PageSizePlugin = function() {
  3. Ext.ux.PageSizePlugin.superclass.constructor.call(this, {
  4. store: new Ext.data.SimpleStore({
  5. fields: ['text', 'value'],
  6. data: [['10', 10], ['20', 20], ['30', 30], ['50', 50], ['100', 100]]
  7. }),
  8. mode: 'local',
  9. displayField: 'text',
  10. valueField: 'value',
  11. editable: false,
  12. allowBlank: false,
  13. triggerAction: 'all',
  14. width: 60
  15. });
  16. };
  17. Ext.extend(Ext.ux.PageSizePlugin, Ext.form.ComboBox, {
  18. init: function(paging) {
  19. paging.on('render', this.onInitView, this);
  20. },
  21. onInitView: function(paging) {
  22. paging.add('-',
  23. this,
  24. ' Items per page'
  25. );
  26. this.setValue(paging.pageSize);
  27. this.on('select', this.onPageSizeChanged, paging);
  28. },
  29. onPageSizeChanged: function(combo) {
  30. this.pageSize = parseInt(combo.getValue());
  31. this.doLoad(0);
  32. }
  33. });