Panel.js 2.1 KB

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