Forum Discussion

Lisha's avatar
Lisha
Cloud Apps
08-18-2022
Solved

Add link to widget title

Hello,

I have a requirement to add a URL to the widget title so the users will be redirected to a page that will give them more information about the widget data. 

Can I achieve these 2 things for all widget types ? 

NOTE : 

I have already gone through below links and tried them. However, they are different from what I want to achieve.

https://community.sisense.com/t5/build-analytics/add-description-to-widget/td-p/3861

https://www.binextlevel.com/post/add-button-to-sisense-widget

FYI, some of my widgets are having JTDs. So on click of those widgets, I am redirected to another dashboard. 

  • Here is the widget script

    widget.on('buildquery', function(se, ev){
    
    		$(`widget[widgetid="${ev.widget.oid}"] .transput-holder`).empty()
    		$(`widget[widgetid="${ev.widget.oid}"] .transput-holder`).append('<a href="https://www.sisense.com/" target="_blank" title="My test tooltip 1">My Title 1</a>')
    		
    		$(`widget[widgetid="${ev.widget.oid}"] widget-title`).empty()
    		$(`widget[widgetid="${ev.widget.oid}"] widget-title`).append('<a href="https://www.sisense.com/" target="_blank" title="My test tooltip 1">My Title 1</a>')
    	
    })

    Remove 'title' attribute from above script, if you don't want tooltip on clickable title.

    To add tooltip without clickable link:

    widget.on('domready', function(se){
    	$(`widget[widgetid="${se.oid}"] .transput-holder .transput-caption`).attr('title', 'test tooltip')
    	$(`widget[widgetid="${se.oid}"] widget-title`).attr('title', 'test tooltip')
    })

    -Hari

     

5 Replies

Replies have been turned off for this discussion
  • harikm007's avatar
    harikm007
    Data Warehouse

    Hi Lisha ,

    Check if this dashboard script works for you:

    
    dashboard.on('widgetbuildquery', function(se, ev){
    	
    	var widgetList = {
    		'62d69b0258d2ad234e93e56d': '<a href="https://www.sisense.com/" target="_blank" title="My test tooltip 1">My Title 1</a>',
    		'45dfa07e58t512002e94dt54': '<a href="https://www.w3schools.com" target="_blank" title="My test tooltip 2">My Title 2</a>'
    	}
    	if(widgetList[ev.widget.oid] != undefined)
    	{
    		$(`widget[widgetid="${ev.widget.oid}"] .transput-holder`).empty()
    		$(`widget[widgetid="${ev.widget.oid}"] .transput-holder`).append(widgetList[ev.widget.oid])
    		
    		$(`widget[widgetid="${ev.widget.oid}"] widget-title`).empty()
    		$(`widget[widgetid="${ev.widget.oid}"] widget-title`).append(widgetList[ev.widget.oid])
    	}
    	
    })

    -Hari

    • Lisha's avatar
      Lisha
      Cloud Apps

       

      Hi Hari,

      I was looking for separate scripts - one where the widget title is a clickable link and another where a tooltip appears on hover. 
      Also, is it possible to have widget level scripts and not dashboard level ?

      Thanks for your help

       

      • harikm007's avatar
        harikm007
        Data Warehouse

        Here is the widget script

        widget.on('buildquery', function(se, ev){
        
        		$(`widget[widgetid="${ev.widget.oid}"] .transput-holder`).empty()
        		$(`widget[widgetid="${ev.widget.oid}"] .transput-holder`).append('<a href="https://www.sisense.com/" target="_blank" title="My test tooltip 1">My Title 1</a>')
        		
        		$(`widget[widgetid="${ev.widget.oid}"] widget-title`).empty()
        		$(`widget[widgetid="${ev.widget.oid}"] widget-title`).append('<a href="https://www.sisense.com/" target="_blank" title="My test tooltip 1">My Title 1</a>')
        	
        })

        Remove 'title' attribute from above script, if you don't want tooltip on clickable title.

        To add tooltip without clickable link:

        widget.on('domready', function(se){
        	$(`widget[widgetid="${se.oid}"] .transput-holder .transput-caption`).attr('title', 'test tooltip')
        	$(`widget[widgetid="${se.oid}"] widget-title`).attr('title', 'test tooltip')
        })

        -Hari