Guest User

Untitled

a guest
Mar 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. qx.Class.define("qx.ui.table.pane.ScrollerMod",
  2. {
  3. extend : qx.ui.table.pane.Scroller,
  4.  
  5. members :
  6. {
  7. _blurCellEditorListenerId : null,
  8.  
  9.  
  10. startEditing : function () {
  11. console.log('startEditing');
  12. var oldCellEditor = this._cellEditor;
  13.  
  14. var startedEditing = this.base(arguments);
  15. if (startedEditing) {
  16. if (this._blurCellEditorListenerId !== null && oldCellEditor !== null) {
  17. oldCellEditor.removeListenerById(this._blurCellEditorListenerId);
  18. }
  19.  
  20. this._blurCellEditorListenerId = null;
  21.  
  22. if (!(this._cellEditor instanceof qx.ui.window.Window)) {
  23. this._blurCellEditorListenerId = this._cellEditor.addListenerOnce('blur', this._onBlurCellEditorStopEditing, this);
  24. console.log('hash: ' + this._cellEditor.$$hash);
  25. console.log('_blurCellEditorListenerId: ' + this._blurCellEditorListenerId);
  26. }
  27. }
  28.  
  29. return startedEditing;
  30. },
  31.  
  32.  
  33. cancelEditing : function () {
  34. console.log('cancelEditing');
  35. if (this.isEditing()) {
  36. if (this._blurCellEditorListenerId) {
  37. this._cellEditor.removeListenerById(this._blurCellEditorListenerId);
  38. this._blurCellEditorListenerId = null;
  39. }
  40.  
  41. this.base(arguments);
  42. }
  43. },
  44.  
  45.  
  46. /**
  47. * Stop editing whenever the cell editor blurs.
  48. */
  49. _onBlurCellEditorStopEditing : function (e) {
  50. "use strict";
  51. if (this._cellEditor === e.getTarget()) {
  52. this.error('stacktrace');
  53. console.log('_onBlurCellEditorStopEditing');
  54. console.log('hash: ' + this._cellEditor.$$hash);
  55. console.log('_blurCellEditorListenerId: ' + this._blurCellEditorListenerId);
  56. this.stopEditing();
  57. }
  58. }
  59. }
  60. });
  61.  
  62. function createRandomRows(rowCount) {
  63. var rowData = [];
  64. var now = new Date().getTime();
  65. var dateRange = 400 * 24 * 60 * 60 * 1000; // 400 days
  66. var nextId = 0;
  67. for (var row = 0; row < rowCount; row++) {
  68. var date = new Date(now + Math.random() * dateRange - dateRange / 2);
  69. rowData.push([ nextId++, Math.random() * 10000, date, (Math.random() > 0.5) ]);
  70. }
  71. return rowData;
  72. }
  73.  
  74.  
  75. // window
  76. var win = new qx.ui.window.Window("Table").set({
  77. layout : new qx.ui.layout.Grow(),
  78. allowClose: false,
  79. allowMinimize: false,
  80. contentPadding: 0
  81. });
  82. this.getRoot().add(win);
  83. win.moveTo(30, 40);
  84. win.open();
  85.  
  86. // table model
  87. var tableModel = new qx.ui.table.model.Simple();
  88. tableModel.setColumns([ "ID", "A number", "A date", "Boolean" ]);
  89. tableModel.setData(createRandomRows(1000));
  90.  
  91. // make second column editable
  92. tableModel.setColumnEditable(1, true);
  93.  
  94. // table
  95. var table = new qx.ui.table.Table(tableModel, {
  96. tablePaneScroller : function(obj) { return new qx.ui.table.pane.ScrollerMod(obj) }
  97. }).set({
  98. decorator: null
  99. });
  100. win.add(table);
  101.  
  102. var tcm = table.getTableColumnModel();
  103.  
  104. // Display a checkbox in column 3
  105. tcm.setDataCellRenderer(3, new qx.ui.table.cellrenderer.Boolean());
  106.  
  107. // use a different header renderer
  108. tcm.setHeaderCellRenderer(2, new qx.ui.table.headerrenderer.Icon("icon/16/apps/office-calendar.png", "A date"));
Add Comment
Please, Sign In to add comment