How can I add Tooltip for child grid (For
Header and grid element) in hierarchy data binding, I have given following
image for sample.
|
<ejs-tooltip #tooltip id="tooltip" target=".e-headercell,.e-rowcell">
<ejs-grid #grid id='Grid' [dataSource]='parentData' (mouseover)="tooltipValue($event)" [childGrid]='childGrid'>
</ejs-grid>
</ejs-tooltip> |
|
// Grid’s ‘mouseover’ event handler
tooltipValue(args) {
// Tooltip content is updated
this.tooltipObj.content = (args.target as any).innerText;
} |
|
// Parent Grid’s detailDataBound event handler
onDetailDataBound(args) {
// Current child Grid element is retrieved and ‘mouseover’ event is bound to it
var curChildGridEle = args.detailElement.querySelector('.e-grid');
curChildGridEle.addEventListener('mouseover', this.onMouseOver.bind(this));
// Tooltip is initialized and rendered on the current child Grid
const tooltipObj: Tooltip = new Tooltip({
target: '.e-headercell,.e-rowcell'
}, curChildGridEle as HTMLTableCellElement);
} |
|
// Child Grid’s ‘mouseover’ event handler
onMouseOver(args) {
// Retrieves the closest tooltip class(Current child Grid element will be returned as the tooltip is bound to it)
var instances = args.target.closest('.e-tooltip').ej2_instances;
var instLength = instances.length;
// The Grid will have multiple instances of different components set on it
// Now since tooltip is bound to the Grid after Grid initialization, it will be the final instance, based on which it is retrieved
var tooltipInst = instances[instLength - 1];
// Tooltip content is updated
tooltipInst.content = (args.target as any).innerText;
} |
|
// Tooltip’s beforeOpen event handler
beforeOpen(args) {
// Tooltip open is prevented if there is not inner text
if (args.target.innerText === "") {
args.cancel = true;
}
} |
|
// Tooltip’s beforeOpen event handler
beforeOpen(args) {
// Tooltip open is prevented if it contains the specified target class
if (args.target.querySelector(".e-checkbox-wrapper") || args.target.querySelector(".e-radio")) {
args.cancel = true;
}
} |