Project

General

Profile

Click on WTable to return row info

Added by Michelle Dupuis almost 5 years ago

I have created a WTable and I would like a clicked event for the table to tell me which row was clicked. It appears that the clicked event only returns mouse coordinates.

Is it possible for a clicked event to return a pointer to the row widget instead?

The only way I can see doing this is to attach a clicked event to every single row (or cell) - which feels like the wrong approach. Has anyone else done this?


Replies (1)

RE: Click on WTable to return row info - Added by Roel Standaert almost 5 years ago

WTable is a relatively "dumb" and straightforward implementation of a <table> element in HTML. It's more like a WContainerWidget with a structure, so a rather low level abstraction.

The approach you would use to react to a click somewhere on the WTable is exactly as you suggest, by setting a clicked event on every individual WTableCell (or attaching the clicked event of the table to some custom JavaScript that figures out which cell it was you clicked on).

WTableView has row/cell selection features (among a lot of other features), so if you're looking for a more feature rich table, you may want to take a look at WTableView: https://www.webtoolkit.eu/widgets/trees-tables/mvc-table-views.

Regards,

Roel

    (1-1/1)