Can I add an HTML-style tooltip to a Dojo DataGrid?
I want to add a tooltip to certain cells of a dojo DataGrid, but I don't want to use dojo tooltips. I want to use HTML tooltips so they have a consistent look-and-feel as the tooltips on my buttons.
In a Dojo Tree, there is a tooltip attribute that does exactly this. Is there a way to开发者_如何学JAVA do this for DataGrids?
This can be done by writing a custom format function for the cell.
You need a custom structure object when you create the grid.
May look like this:
var layout = [[{
name: 'Type',
field: 'type',
width: 2,
},{
name: 'Name',
field: 'name',
width: 'auto',
defaultValue: '',
editable: true,
formatter: dojo.hitch(this, this.formatNameCell)
}]];
Then define a format function for the 'Name' cells:
formatNameCell(name){
return "<span title='" + name + "'>" + name + "</span>";
}
精彩评论