Thursday, December 11, 2008

How do I tell if they clicked a row in the table versus its body?

In our app, we have a dblClick clientListener as a direct child of a table. If the user clicks a row, we want to show them the edit popup for that row, if they click in white space (i.e. the are beneath the rows), we want to create a new row and show the popup to edit that new row. The source for either click will be the table itself, however, the target will be what we are interested in. To ensure that our code remains cross-browser compatible, we'll use methods made available by client-side ADF.

From the ADF js file, I have plucked the following:

var agent = AdfAgent.AGENT, domEvent = evt.getNativeEvent();
var target = agent.getEventTarget(domEvent);
var tablePeer = table.getPeer();
var attrs = tablePeer.GetRowKeyAndRow(target,tablePeer.getDomElement());


If attrs is null, then the user clicked within the table body and not on a row. If attrs is not null then the user clicked on an actual row.

No comments: