AddDetail.js 957 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * 明细行插入按钮
  3. */
  4. Ext.define('erp.view.core.button.AddDetail',{
  5. extend: 'Ext.Button',
  6. alias: 'widget.erpAddDetailButton',
  7. iconCls: 'x-button-icon-add',
  8. cls: 'x-btn-tb',
  9. // id: 'adddetail',
  10. tooltip: $I18N.common.button.erpAddButton,
  11. disabled: true,
  12. initComponent : function(){
  13. this.callParent(arguments);
  14. },
  15. listeners: {
  16. afterrender: function(){
  17. this.grid = this.ownerCt.ownerCt;
  18. }
  19. },
  20. handler: function(btn){
  21. var me = this,
  22. grid = me.grid, store = grid.store,
  23. record = grid.selModel.lastSelected;
  24. if (record) {
  25. if(grid.detno) {
  26. var detno = Number(record.data[grid.detno]),d = detno;
  27. store.each(function(item){
  28. d = item.data[grid.detno];
  29. if(Number(d) > detno) {
  30. item.set(grid.detno, Number(d) + 1);
  31. }
  32. });
  33. var o = new Object();
  34. o[grid.detno] = detno + 1;
  35. grid.store.insert(store.indexOf(record) + 1, o);
  36. }
  37. }
  38. }
  39. });