How to pass the first click event from one subtab to another subtab in dashboard?

Tiago shared this question 3 months ago
Completed

Hi.

So far, I have 1 dashboard with 2 sub tabs. The first sub tab presents generic KPIs, for example number of visits Today, or number of visits this Week.

The first sub tab offers the opportunity so see details for that KPIs. If the user clicks in one of those KPIs, the dashboard changes from the first to the second sub tab [configured in its properties (Action -> Go to sub tab and write 2]. In sub tab 2, there is a table and a filter to show the details for the desired period (Today, This Week,...).

To implement the correct filter values, I use Code Mode.

My first approach was to create the following javascript in the second sub tab:

document.addEventListener('click', (e)=>{TestFunction(e);}, false);<br><br>function TestFunction(e){<br>    e = e || window.event;<br>    var target = e.target || e.srcElement,<br>        text = target.textContent || target.innerText;   <br>    var ButtonClickedUuid = e.target.getAttribute("clip-path");<br>    <br>  // More code exists to implement the desire filter's value.<br>}


This works fine, but not for the first time. I think it is because the click event precedes the creation of the event listener.

My second approach was to add the event listener, different from the first approach, in the first sub tab, and the function itself in the second sub tab:


// Event listener in the first approach was commented and the this code was added in the first sub tab:<br>this.apis.dashboard.getSubTabByPosition(1).addEventListener('click', (e)=>{TestFunction(e);}, false);<br>// The function is the same and it stays in the second sub tab.

This second approach never works.

What I must do to get the code working?

Thank you.

Best regards,

Tiago Marçal

Replies (3)

photo
1

Hi Tiago,

Thanks for reaching out to support with your question. This type of custom code assistance is unfortunately out-of-scope for support, however our consulting partners are often able to help implement this type of integrated solution, recommendation would be to reach out to your CSM to schedule a call on this if needed. Hope this helps, let me know if you have any additional questions.

Thanks,
Eric

photo
1

Hi Eric.

Thanks.

It is everything.

Best regards,

Tiago

photo
1

Hi Tiago,

Thanks for the confirmation here, I'll mark this ticket as Completed at this time. Feel welcome to reach out in the future.

Thanks,
Eric

Leave a Comment
 
Attach a file