[Wijmo][MultiRow]单元格中如何添加toolTip
如题,目前项目前端使用了Angular TypeScript,请麻烦提供一下MultiRow的例子或者请提供一下是否可以解决的思路。
谢谢了。
本帖最后由 JeffryLI 于 2018-12-24 09:22 编辑
您好,在flexgrid 下有一个hittest的方法,可以用来检测鼠标行为,然后再结合wijmo的tooltip来完成这样的功能。 onload = function() {
// create some random data
var countries = 'US,Germany,UK,Japan'.split(',');
var data = [];
for (var i = 0; i < 20; i++) {
data.push({
id: i,
country: countries,
sales: Math.random() * 10000,
expenses: Math.random() * 5000,
overdue: i % 4 == 0
});
}
// bind a grid to the data
var theGrid = new wijmo.grid.FlexGrid('#theGrid', {
itemsSource: new wijmo.collections.CollectionView(data, {
groupDescriptions: [ 'country' ] // group data by country
}),
formatItem: function(s, e) {// add 'button' to country cells
if (e.panel == s.cells) {
if (s.columns.binding == 'country') {
var html = '<span class="my-button">⬤</span> ' + e.cell.innerHTML;
e.cell.innerHTML = html;
}
}
}
});
// monitor and log mouse moves
var logEl = document.getElementById('log');
theGrid.addEventListener(theGrid.hostElement, 'mousemove', function(e) {
var ht = theGrid.hitTest(e);
var logText = wijmo.format('panel <b>{cellType}</b> row <b>{row}</b> col <b>{col}</b>', {
cellType: wijmo.grid.CellType,
row: ht.row,
col: ht.col
});
if (e.target.classList.contains('my-button')) {
logText += ' (fake button!)';
} else if (e.target.tagName == 'INPUT' && e.target.type == 'checkbox') {
logText += ' (checkbox!)';
} else if (ht.panel == theGrid.cells) {
if (theGrid.rows instanceof wijmo.grid.GroupRow) {
logText += ' (group row)';
} else {
logText += ' (value: <b>' + theGrid.cells.getCellData(ht.row, ht.col, true) + '</b>)';
}
}
logEl.innerHTML = logText;
});
}
页:
[1]