Skip to content

Instantly share code, notes, and snippets.

@milandamen
Created March 12, 2018 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milandamen/d288453491f49923e3c5d6857ee19747 to your computer and use it in GitHub Desktop.
Save milandamen/d288453491f49923e3c5d6857ee19747 to your computer and use it in GitHub Desktop.
Qooxdoo issue 9504 Table scroller cell editor focus not working
qx.Class.define("qx.ui.table.pane.ScrollerMod",
{
extend : qx.ui.table.pane.Scroller,
members :
{
_blurCellEditorListenerId : null,
startEditing : function () {
console.log('startEditing');
var oldCellEditor = this._cellEditor;
var startedEditing = this.base(arguments);
if (startedEditing) {
if (this._blurCellEditorListenerId !== null && oldCellEditor !== null) {
oldCellEditor.removeListenerById(this._blurCellEditorListenerId);
}
this._blurCellEditorListenerId = null;
if (!(this._cellEditor instanceof qx.ui.window.Window)) {
this._blurCellEditorListenerId = this._cellEditor.addListenerOnce('blur', this._onBlurCellEditorStopEditing, this);
console.log('hash: ' + this._cellEditor.$$hash);
console.log('_blurCellEditorListenerId: ' + this._blurCellEditorListenerId);
}
}
return startedEditing;
},
cancelEditing : function () {
console.log('cancelEditing');
if (this.isEditing()) {
if (this._blurCellEditorListenerId) {
this._cellEditor.removeListenerById(this._blurCellEditorListenerId);
this._blurCellEditorListenerId = null;
}
this.base(arguments);
}
},
/**
* Stop editing whenever the cell editor blurs.
*/
_onBlurCellEditorStopEditing : function (e) {
"use strict";
if (this._cellEditor === e.getTarget()) {
this.error('stacktrace');
console.log('_onBlurCellEditorStopEditing');
console.log('hash: ' + this._cellEditor.$$hash);
console.log('_blurCellEditorListenerId: ' + this._blurCellEditorListenerId);
this.stopEditing();
}
}
}
});
function createRandomRows(rowCount) {
var rowData = [];
var now = new Date().getTime();
var dateRange = 400 * 24 * 60 * 60 * 1000; // 400 days
var nextId = 0;
for (var row = 0; row < rowCount; row++) {
var date = new Date(now + Math.random() * dateRange - dateRange / 2);
rowData.push([ nextId++, Math.random() * 10000, date, (Math.random() > 0.5) ]);
}
return rowData;
}
// window
var win = new qx.ui.window.Window("Table").set({
layout : new qx.ui.layout.Grow(),
allowClose: false,
allowMinimize: false,
contentPadding: 0
});
this.getRoot().add(win);
win.moveTo(30, 40);
win.open();
// table model
var tableModel = new qx.ui.table.model.Simple();
tableModel.setColumns([ "ID", "A number", "A date", "Boolean" ]);
tableModel.setData(createRandomRows(1000));
// make second column editable
tableModel.setColumnEditable(1, true);
// table
var table = new qx.ui.table.Table(tableModel, {
tablePaneScroller : function(obj) { return new qx.ui.table.pane.ScrollerMod(obj) }
}).set({
decorator: null
});
win.add(table);
var tcm = table.getTableColumnModel();
// Display a checkbox in column 3
tcm.setDataCellRenderer(3, new qx.ui.table.cellrenderer.Boolean());
// use a different header renderer
tcm.setHeaderCellRenderer(2, new qx.ui.table.headerrenderer.Icon("icon/16/apps/office-calendar.png", "A date"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment