Hi Daniel,

If you subclass DefaultDataTable there is a protected method call newCellItem(...) that you can use to attach the onclick class onto the <td>.

like:

class MyDataTable extends DefaultDataTable {
/* (non-Javadoc)
* @see org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable#newCellItem(java.lang.String, int, org.apache.wicket.model.IModel)
    */
   @Override
   protected Item newCellItem(String id, int index, IModel model) {


       Item cell = super.newCellItem(id, index, model);


cell.add(new AttributeAppender("onclick", new Model ("someJavascriptCall();"));

       return cell;
   }
}

Alternately you can use a custom column implementation like the FragrementColumn and add the onclick when the cell is created like:

class MyOnClickColumn extends AbstractColumn {
...
public void populateItem(Item cellItem, String componentId, IModel rowModel)
   {
Label cell = new Label(componentId, new PropertyModel(rowModel, property))

cell.add (new AttributeAppender("onclick", new Model ("someJavascriptCall();"));

       cellItem.add(cell);
   }
}


I think the second version would attach the onclick to the label within the <td></td> of a cell.

Regards,

Mike
I dont know wicketopia project (and any of its classes like FragmentColumn)
so I can misunderstand your idea but as far as I am able to read that code
It looks like you are adding a link to the table cell, not making a cell
itself a link.

If I understand your code it is familar to:

<td>&lt;a&gt;text&lt;/a&gt;</td>

but Im wondering how to achive:
<td on click="xyz">text</td>

where xyz is code generated by Wicket (like in Link component class)

If I misundestood you could you give me some more details hot to make cell
itself a link ? (not adding a link to the cell) ?

Regards Daniel



jwcarman wrote:
Here's an example where I put a remove link in a DefaultDataTable cell:

https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java


On Tue, Oct 28, 2008 at 6:33 AM, dlipski <[EMAIL PROTECTED]>
wrote:
Hi

I have one short question:
How to make entire cell in a DataTable a link ?
I've read that Link component can be attached not only to &lt;a&gt; tags
but
also to any other html elements (like <tr> and <td>) but I dont know how
to
use it with DataTable API.

Regards Daniel
--
View this message in context:
http://www.nabble.com/DataTable-cell-link-tp20204702p20204702.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to