Something like this:

@MixinAfter
public class RowEvent {
        @InjectContainer
        private Grid grid;
        
        @Inject
        private JavaScriptSupport jss;
        
        @Inject
        private ComponentResources componentResrouces;
        
        @Parameter(required=true)
        private String event;
        
        public void afterRender(MarkupWriter writer) {
                GridDataSource dataSource = grid.getDataSource();
                Element tbody = writer.getElement().find("tbody");
                List<Node> children = tbody.getChildren();
                for (int i = 0; i < children.size(); ++i) {
                        Element tr = (Element) children.get(i);
                        String rowId = jss.allocateClientId("row");
                        
                        // give each row an id
                        tr.attribute("id", rowId); 
                        
                        // this will be passed as a parameter to the serverside 
event
                        Object rowContext = dataSource.getRowValue(i);
                        
                        // this event will bubble up to the containing page / 
component
                        Link eventLink = 
componentResrouces.createEventLink(event, rowContext);
                        
                        // observe the 'click' event and fire the eventlink
                        jss.addScript("Event.observe('%s', 'click', function() {
window.location.href = '%s' })", rowId, eventLink);
                }
        }
}

Usage:
<t:grid source="..." mixins="rowEvent" event="rowClicked">

public void onRowClicked(RowType rowContext) {
   // do stuff
}



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Render-whole-table-grid-row-as-a-link-tp5717388p5717399.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to