Hi, in case you haven't come to a solution on your side:
In the provided playground code you can see that (and how) it works.
The 'myproject.Header' class just stores the reference to a created HeaderCell
and forwards the set 'setButtonSearchVisibility' functionality.
I hope you see what I've done.
/Peter
--
** Unsere Veranstaltungen 2015
transport logistic München Halle B2, Stand 317/518 5.5.-8.5.2015
MöLo Kassel 18.6.-20.6.2015
Postexpo Paris 29.9.-1.10.2015
** NEU: Unser BLOG
telematics-magazine.com
qx.Class.define("myproject.HeaderCell",
{
extend : qx.ui.table.headerrenderer.HeaderCell,
construct : function()
{
this.base(arguments);
var gridLayout = new qx.ui.layout.Grid();
gridLayout.setColumnFlex(0, 1);
this.iconContainer = new qx.ui.container.Composite(gridLayout);
this._add(this.iconContainer, {row: 0, column: 2});
var iconSort = this.getChildControl("sort-icon");
this.iconContainer.add(iconSort, {row: 1, column: 1});
this._createChildControl("buttonSearch");
},
properties:
{
buttonSort :
{
init : null,
nullable : true
}
},
members :
{
iconContainer: null,
_createChildControlImpl : function(id, hash)
{
var control;
switch(id)
{
case "buttonSearch":
control = new qx.ui.basic.Image("icon/16/actions/system-search.png");
this.iconContainer._add(control, {row: 2, column: 1});
break;
}
return control || this.base(arguments, id);
},
/**
* Note, the 'value' is Boolean, not "visible"|"excluded"|"hidden" as one
* might expect
* @param value {Boolean} Whether to show the search-button
*/
setButtonSearchVisibility: function (visible) {
if(visible){
this._showChildControl("buttonSearch");
}else{
this._excludeChildControl("buttonSearch");
}
},
// Better
// @param value {String} One of "visible", "hidden", "excluded"
setButtonSearchVisibility2 : function (value) {
this._getChildControl("buttonSearch").setVisibility(value);
}
}
});
qx.Class.define("myproject.Header",
{
extend : qx.ui.table.headerrenderer.Default,
members :
{
__headerCell : null, // <= storage, there is no
qx.ui.table.headerrenderer.Default#getHeaderCell()
/**
* Note, the 'value' is Boolean, not "visible"|"excluded"|"hidden" as one
* might expect
* @param value {Boolean} Whether to show the search-button
*/
setButtonSearchVisibility : function (value)
{
if (this.__headerCell) {
this.__headerCell.setButtonSearchVisibility(value);
}
},
// Better
// @param value {String} One of "visible", "hidden", "excluded"
setButtonSearchVisibility2 : function (value) {
this.__headerCell.setVisibility(value);
},
// overridden
createHeaderCell : function (cellInfo)
{
var widget = new myproject.HeaderCell();
this.updateHeaderCell(cellInfo, widget);
this.__headerCell = widget; // <= store reference for later use
return widget;
}
},
destruct : function () {
this._disposeObjects("_headerCell");//@todo: is this needed?
}
});
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++, // ID
Math.random() * 10000, // Number
date, // Date
0===(row%5) // Bold
]);
}
return rowData;
}
// window
var win = new qx.ui.window.Window("Table").set({
layout : new qx.ui.layout.VBox(),
allowClose: false,
allowMinimize: false,
contentPadding: 0
});
this.getRoot().add(win);
win.moveTo(30, 40);
win.open();
// show/hide button
var button = new qx.ui.form.ToggleButton("show/hide").set({
value: true, allowGrowX: false, marginLeft: 100 });
button.addListener("changeValue", function (e) {
var _tcm = table.getTableColumnModel();
_tcm.getHeaderCellRenderer(1).setButtonSearchVisibility(e.getData() );
});
// table model
var tableModel = new qx.ui.table.model.Simple();
tableModel.setColumns([ "ID", "A number", "A date", "Bold" ]);
tableModel.setData(createRandomRows(1000));
// make second column editable
tableModel.setColumnEditable(1, true);
// table
var table = new qx.ui.table.Table(tableModel).set({
decorator: null
});
win.add(button);
win.add(table);
var tcm = table.getTableColumnModel();
// Display a boolean at column 3
tcm.setDataCellRenderer(3, new qx.ui.table.cellrenderer.Boolean());
// use a different header renderer
tcm.setHeaderCellRenderer(1, new myproject.Header());
tcm.setHeaderCellRenderer(2, new
qx.ui.table.headerrenderer.Icon("icon/16/apps/office-calendar.png", "A date"));
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel