PanelController.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Controller for several grid examples (such as BasicGrid).
  3. *
  4. * Provides column renderers and handlers for the ActionColumn and buttons.
  5. */
  6. Ext.define('uas.view.grid.basic.PanelController', {
  7. extend: 'Ext.app.ViewController',
  8. alias: 'controller.basic-grid',
  9. onApprove: function (grid, rowIndex, colIndex) {
  10. var rec = grid.getStore().getAt(rowIndex);
  11. Ext.Msg.alert('Approve', rec.get('name'));
  12. },
  13. onDecline: function(grid, rowIndex, colIndex) {
  14. var rec = grid.getStore().getAt(rowIndex);
  15. Ext.Msg.alert('Decline', rec.get('name'));
  16. },
  17. renderChange: function (value) {
  18. return this.renderSign(value, '0.00');
  19. },
  20. renderPercent: function (value) {
  21. return this.renderSign(value, '0.00%');
  22. },
  23. renderSign: function (value, format) {
  24. var text = Ext.util.Format.number(value, format),
  25. tpl = this.signTpl,
  26. data = this.data;
  27. if (Math.abs(value) > 0.1) {
  28. if (!tpl) {
  29. this.signTpl = tpl = this.getView().lookupTpl('signTpl');
  30. this.data = data = {};
  31. }
  32. data.value = value;
  33. data.text = text;
  34. text = tpl.apply(data);
  35. }
  36. return text;
  37. }
  38. });