Forum Discussion

amritbhgt's avatar
amritbhgt
Cloud Apps
11-30-2023
Solved

Add tooltip for column headers in a Table

Hi All,   I want add tooltips for all the columns present in a table widget .    
  • rapidbisupport's avatar
    rapidbisupport
    12-04-2023

    You're right, this is for a Pivot Table. Thanks for the clarification.

    You can achieve what you're after for a Table widget using the mousehover event.

    var $dom = prism.$injector.get('ux-controls.services.$dom')
    var tip = null
    
    widget.on('ready', (w, args) => {
    	$('th').on('mouseover', function (e) {
    		var scope = prism.$ngscope.$new()
    		console.log($(this).text())
    		
    		let myTitle = $(this).text()
    		
    		if ($(this).data().dim === '[Driver.driver]') {
    			myTitle = `Driver<br>This is description text` 
    		}
    		
    		tip = $dom.tip({
    			template: `<span>${myTitle}</span>`,
    			scope: scope,
    		}, {
    			placement: { place: 'l', anchor: 't' },
    			radial: false
    		})
    	   
    		tip.activate({x: e.clientX, y: e.clientY, space: 5})
    	})
    })
    

     

    This will behave erratically if you have multiple tables on the same dashboard, and will need rework on the selector above '$('th'). ...'.

    Let me know if this works for you!

    Thanks,

    Daniel

    RAPID BI

    daniel.ranisavljevic@rapidbi.com.au

    RAPID BI - Sisense Professional Services | Implementations | Custom Add-ons