On Mon, Aug 2, 2010 at 07:39, Mengu <[email protected]> wrote:
>
> Dear Derrell,
>
> I have followed your advice on inheriting qx.ui.table.columnmenu.Button. I
> currently have this: http://pastie.org/private/08b3wp0w3iyiz50x6rk6nq
Here's a playground snippet that shows this working. Your code had lots of
superfluous junk in it, making it difficult to track down what was going on.
Notice that there's nothing extra or unnecessary in the following class, so
one can see what's going on.
The biggest problem with your code was that you weren't returning any value
from the factory() method.
qx.Class.define("my.ColumnMenuButton",
{
extend: qx.ui.table.columnmenu.Button,
members :
{
factory: function(item, options)
{
var control = this.base(arguments, item, options);
// Add a listener of our own to know when a menu button is pressed
if (item == "menu-button")
{
control.addListener(
"changeValue",
function(e)
{
alert("Menu button: '" + this.getLabel() + "', " +
"visibility: " + (this.getVisible() ? "true" : "false"));
});
}
return control;
}
}
});
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;
}
// 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);
// We want a custom column menu button
var custom =
{
columnMenu : function()
{
return new my.ColumnMenuButton();
}
};
// table
var table = new qx.ui.table.Table(tableModel, custom);
this.getRoot().add(table, { edge : 10 });
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"));
> the next question is, I have seen that the table columns are menu items in
> the column menu button, so how should I write an event listener in my
> column
> button so whenever the menu items are clicked to be invisible or visible,
> my
> action runs then?
>
See the listener function I added to the factory method.
Derrell
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel