Add a button in the widget Data Table from Instance Definition

TWCarlsson
Kilo Explorer

I am using a cloned version of the widget "Data Table from Instance Definition".
How can I add a button and place it either in front of the Keyword Search or to the right of filter?find_real_file.png 

My Button shall have the same functionality as the Link button widget, but I don't know how to place it where I want it.

I can place it within the Page, but then I think it takes up too much space and messes up the view a bit. The best is to place it to the right of the filter.

5 REPLIES 5

Cuong Phan
Kilo Sage

Hi,

 

You can add this to client script of that widget, added 2 seconds to wait for widget to show up.

setTimeout(function(){
var searchDOM = document.querySelector('form[ng-if="data.hasTextIndex"] div')
searchDOM.insertAdjacentHTML("beforebegin", "<div class='btn btn-primary stying'>My button</p>");
},2000);

 

and add stying class in CSS to make it pretty

 

find_real_file.png

 

Regards,
Cuong Phan
ServiceNow Technical Lead

Thanks for your reply.

Did you add your code in the Data Table widget or in the Data Table from Instance definition?

I added it in Data Table from Instance definition, and the button does not show.

 

//Tor

Hi,

To my previous question, I now added it in the Data Table widget and it shows. I even styled it to look like a link.

Next challenge is to get this button to open up a specific knowledge article in my instance.

I have tried to insert ng-href in your code without luck.

 

//Tor

Hi,

 

Please try this instead

 

searchDOM.insertAdjacentHTML("beforebegin", '<a class="btn btn-primary" href="/yourURL" target="_blank" >My button</a>');

Regards,
Cuong Phan
ServiceNow Technical Lead