Reputation: 41
I am currently working on modifying the logic to find and focus on the desired row in a table. https://qooxdoo.org/qxl.apiviewer/#qx.ui.table.Table~setFocusedCell!method_public
var table = new qx.ui.table.Table(tableModel);
// some logics for finding matched row
table.setFocusedCell(col_Idx, row_idx, true);
In certain cases, the code above does not properly scroll to the desired row. This is likely because the setFocusedCell() function is not guaranteed to execute after the table widget has been fully rendered. One possible solution is to handle the focus logic after the table has finished rendering using the appear event.
var table = new qx.ui.table.Table(tableModel);
table.addListenerOnce("appear", () => {
// some logics for finding matched row
table.setFocusedCell(col_Idx, row_idx, true);
});
However, the above logic only works when the table is newly created.
I am planning to modify the code to ensure that the setFocusedCell() function is executed after the widget has been fully rendered, using async sleep(). Do you have any other suggestions for a better approach?
And if there is any incorrect understanding or helpful information related to qooxdoo, please let me know. Thank you.
Upvotes: 1
Views: 64
Reputation: 460
You could use some mix of event appear
and promise concept.
If the event is emitted one time then promise will be resolved and in any place of code you could attach method then
to the promise and execute your specific code.
Consider this approach as advanced flag.
const col_Idx = 1;
const row_idx = 1;
const promise = new Promise(function(resolve, reject){
table.addListenerOnce("appear", () => {
resolve();
});
}, this);
promise.then(function(){
table.setFocusedCell(col_Idx, row_idx, true);
});
Upvotes: 1