Panel.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. 'uas.data.Company',
  13. 'uas.model.Company',
  14. 'uas.store.Companies'
  15. ],
  16. bind: '{companies}',
  17. viewModel: {
  18. stores: {
  19. companies: {
  20. type: 'companies',
  21. autoLoad: true,
  22. }
  23. }
  24. },
  25. profiles: {
  26. classic: {
  27. width: 600,
  28. pricechangeWidth: 100,
  29. percentChangeColumnWidth: 100,
  30. lastUpdatedColumnWidth: 100
  31. },
  32. neptune: {
  33. width: 600,
  34. pricechangeWidth: 100,
  35. percentChangeColumnWidth: 100,
  36. lastUpdatedColumnWidth: 100
  37. },
  38. graphite: {
  39. width: 750,
  40. pricechangeWidth: 110,
  41. percentChangeColumnWidth: 120,
  42. lastUpdatedColumnWidth: 150
  43. }
  44. },
  45. columns: [
  46. { text: "Company", flex: 1, dataIndex: 'name'},
  47. { text: "Price", formatter: 'usMoney', dataIndex: 'price', width: 100},
  48. { text: "Change", dataIndex: 'priceChange', width: 100},
  49. { text: "% Change", dataIndex: 'priceChangePct', width: 100},
  50. { text: "Last Updated", formatter: 'date("m/d/Y")', dataIndex: 'priceLastChange', width: 100}
  51. ],
  52. plugins: {
  53. rowexpander: {
  54. rowBodyTpl: new Ext.XTemplate(
  55. '<p><b>Company:</b> {name}</p>',
  56. '<p><b>Change:</b> {change:this.formatChange}</p>',
  57. {
  58. formatChange: function (v) {
  59. var color = v >= 0 ? 'green' : 'red';
  60. return '<span style="color: ' + color + ';">' +
  61. Ext.util.Format.usMoney(v) + '</span>';
  62. }
  63. })
  64. }
  65. }
  66. });