google api visualization table

4 views
Skip to first unread message

leszek

unread,
Jul 2, 2009, 1:48:56 PM7/2/09
to Google Visualization API
I'm trying to utilize
com.google.gwt.visualization.client.visualizations.Table and I have a
code like that:

-----------------
private class MyHandler extends SelectHandler

@Override
public void onSelect(SelectEvent event) {
JsArray<Selection> sel = ta.getSelections();
Selection se = null;
for (int i = 0; i < sel.length(); i++) {
se = sel.get(i);
.......
}
.....
}
}


Table ta = new Table(getTable(), Table.Options.create());
ta.addSelectHandler(new MyHandler());

--------------------------

It works for me. But the question is:

Is it possible to have absolute position of the cell (row) which
causes this click-event ?

If using standard GWT FlexTable I can retrievie this information by:

FlexTable ta;

public void onCellClicked(SourcesTableEvents sender, int row,
int cell) {
Widget w = ta. getWidget(row,cell);
w. getAbsoluteLeft();
w.getAbsoluteTop();
........
}

ChartMan

unread,
Jul 9, 2009, 10:41:39 AM7/9/09
to google-visua...@googlegroups.com
You cannot obtain the position of the row from the select event itself.

However, on your end, you can add html elements to cells in various rows and once you a select event is triggered the position could be retrieved from those custom elements (based on the row index from the select event).
This is not perfect but it can do the trick.

ChartMan

leszek

unread,
Jul 10, 2009, 3:56:48 AM7/10/09
to Google Visualization API
With a little help of firebug I created code like that and it works
for me.

============================
Table ta;
int row_clicked;
................

Element etd = ta.getElement(); // TD
Element eta= etd.getFirstChildElement(); // TABLE
Element etb = eta.getFirstChildElement(); // TBODY
Element etr = etb.getFirstChildElement(); // TR -
header

int no = 0;
int top = 0;
int left = 0;
int height = 0;
int width = 0;
// remember to skip header
while (etr != null) {
etr = etr.getNextSiblingElement();
if (no == row_clicked) { break; }
no++;
}
if (etr != null) {
top = etr.getAbsoluteTop();
left = etr.getAbsoluteLeft();
height = etr.getOffsetHeight();
width = etr.getOffsetWidth();
} ........
}
Reply all
Reply to author
Forward
0 new messages