Guest User

Untitled

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