Panel.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * @Description:
  3. * @Author: hy
  4. * @Date: 2019-08-15 10:27:49
  5. * @LastEditTime: 2019-08-16 17:13:30
  6. */
  7. /**
  8. * This is an example of using the grid with a RowExpander plugin that adds the ability
  9. * to have a column in a grid which enables a second row body which expands/contracts.
  10. *
  11. * The expand/contract behavior is configurable to react on clicking of the column, double
  12. * click of the row, and/or hitting enter while a row is selected.
  13. */
  14. Ext.define('uas.view.grid.expander.Panel', {
  15. extend: 'Ext.grid.Panel',
  16. xtype: 'grid-expander-panel',
  17. requires: [
  18. 'Ext.grid.plugin.RowExpander'
  19. ],
  20. bind: '{companies}',
  21. viewModel: {
  22. stores: {
  23. companies: {
  24. type: 'companies',
  25. autoLoad: true,
  26. }
  27. }
  28. },
  29. columns: [
  30. { text: "Company", flex: 1, dataIndex: 'name'},
  31. { text: "Price", formatter: 'usMoney', dataIndex: 'price', width: 100},
  32. { text: "Change", dataIndex: 'priceChange', width: 100},
  33. { text: "% Change", dataIndex: 'priceChangePct', width: 100},
  34. { text: "Last Updated", formatter: 'date("m/d/Y")', dataIndex: 'priceLastChange', width: 100}
  35. ],
  36. plugins: {
  37. rowexpander: {
  38. rowBodyTpl: new Ext.XTemplate(
  39. '<p><b>Company:</b> {name}</p>',
  40. '<p><b>Change:</b> {change:this.formatChange}</p>',
  41. {
  42. formatChange: function (v) {
  43. var color = v >= 0 ? 'green' : 'red';
  44. return '<span style="color: ' + color + ';">' +
  45. Ext.util.Format.usMoney(v) + '</span>';
  46. }
  47. })
  48. }
  49. }
  50. });