I kept digging and figured this out (with the previously mentioned
sweetTitles integration):

   class TooltipGeneratingPropertyColumn extends PropertyColumn
    {
       ....
        @Override
        public void populateItem(Item item, String componentId, IModel
model)
        {
            super.populateItem(item, componentId, model);
            String cellValue = ((RowMap)
model.getObject()).getValueAsString(this.getPropertyExpression());

            if (cellValue.length() > 40)
            {
                String truncatedCellValue = cellValue.substring(0,40) +
"...";
                // add code to override the value on the model with
truncatedCellValue here.....  (model specific)
                item.add(new AttributeModifier("showtooltip", true, new
Model("true")));
                item.add(new AttributeModifier("title", true, new
Model(cellValue)));
            }
        }
    }


matttx wrote:
> 
> I'm currently using DataTable (with PropertyColumn's)  to display the
> results sql queries.    Sometimes data for a given column exceeds the
> length that can be formatted well in an html table.    I'd like to
> truncate a column if it exceeds a length of, say, 40, and add a tooltip to
> display the full content of the cell.   
> 
> I've found this reference
> http://cwiki.apache.org/WICKET/how-to-add-tooltips.html, and been able to
> dynamically add a tooltip while generating the table cells. 
> (newCellItem).   However, I don't see (a) a way to retrieve the cell's
> value to insert in a tooltip during newCellItem (with PropertyColumns),
> and (b) a way affect the cell's value to truncate it.    Do I need my own
> custom version of PropertyColumn here?
> 
> Regards
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Add-a-tooltip-to-a-DataTable-for-cells-with-long-content-tf4415379.html#a12598479
Sent from the Wicket - User mailing list archive at Nabble.com.


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

Reply via email to