Dropdown.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /**
  2. * 输入框下拉筛选
  3. */
  4. Ext.define("erp.view.core.trigger.Dropdown", {
  5. extend: "Ext.view.View",
  6. alias: "widget.searchdropdown",
  7. floating: true,
  8. autoShow: false,
  9. autoRender: true,
  10. toFrontOnShow: true,
  11. focusOnToFront: false,
  12. store: Ext.create('Ext.data.Store', {
  13. fields: ["text"],
  14. proxy: {
  15. type: "memory",
  16. reader: {
  17. type: "json"
  18. }
  19. }
  20. }),
  21. trackOver: true,
  22. baseCls: Ext.baseCSSPrefix + 'boundlist',
  23. itemCls: Ext.baseCSSPrefix + 'boundlist-item',
  24. singleSelect: true,
  25. autoScroll: true,
  26. pageStart: 0,
  27. pageSize: 10,
  28. initComponent: function() {
  29. var me = this, baseCls = me.baseCls, itemCls = me.itemCls;
  30. me.selectedItemCls = baseCls + '-selected';
  31. me.overItemCls = baseCls + '-item-over';
  32. me.itemSelector = "." + itemCls;
  33. if (me.floating) {
  34. me.addCls(baseCls + '-floating');
  35. }
  36. this.addEvents("changePage", "footerClick");
  37. this.tpl = new Ext.XTemplate('<tpl for=".">',
  38. '<div class="x-boundlist-item" style="min-width:40px;margin:0px 0px 5px 2px;">',
  39. '<input type="checkbox">&nbsp;&nbsp;{text}</input>',
  40. '</div>',
  41. "</div>",
  42. "</tpl>",
  43. '<div style="background:#e0e0e0;font-weight:800;height:25px;font-size:13px;" class="x-footer">',
  44. '<a href="#" class="x-prev" style="text-decoration:none">&nbsp;&lt;&nbsp;</a>',
  45. '<span>&nbsp;从&nbsp;{[this.getStart()+1]}&nbsp;到&nbsp;{[this.getEnd()]} 共 {[this.getTotal()]}&nbsp;&nbsp;</span>',
  46. '<a href="#" class="x-next" style="text-decoration:none">&nbsp;&gt;&nbsp;</a>',
  47. "</div>",
  48. '<div align="center"><button class="x-confirm">确定</button><button class="x-cancel">取消</button>',
  49. '</div>', {
  50. getTotal: Ext.bind(this.getTotal, this),
  51. getStart: Ext.bind(this.getStart, this),
  52. getEnd: Ext.bind(this.getEnd, this)
  53. });
  54. this.on("afterrender", function() {
  55. this.el.addListener("click", function() {
  56. this.fireEvent("changePage", this, -1);
  57. }, this, {
  58. preventDefault: true,
  59. delegate: ".x-prev"
  60. });
  61. this.el.addListener("click", function() {
  62. this.fireEvent("changePage", this, +1);
  63. }, this, {
  64. preventDefault: true,
  65. delegate: ".x-next"
  66. });
  67. this.el.addListener("click", function() {
  68. this.fireEvent("footerClick", this);
  69. },this, {
  70. delegate: ".x-footer"
  71. });
  72. this.el.addListener("click", function() {
  73. this.fireEvent("confirm", this);
  74. },this, {
  75. delegate: ".x-confirm"
  76. });
  77. this.el.addListener("click", function() {
  78. this.hide();
  79. },this, {
  80. delegate: ".x-cancel"
  81. });
  82. }, this);
  83. this.callParent(arguments);
  84. },
  85. setTotal: function(b) {
  86. this.total = b;
  87. },
  88. getTotal: function() {
  89. return this.total;
  90. },
  91. setStart: function(b) {
  92. this.pageStart = b;
  93. },
  94. getStart: function(b) {
  95. return this.pageStart;
  96. },
  97. getEnd: function(c) {
  98. var d = this.pageStart + this.pageSize;
  99. return d > this.total ? this.total: d;
  100. }
  101. });