56
Views
5
Comments
Solved
Getting header label of data table using javascript
Question

Hi,

Asking for help on my javascript. I just want to get the label of the header of data table using javascript. but no output once i debug it. can someone help me to check my code. Thanks 


2023-10-21 19-42-11
Tousif Khan
Champion
Solution

Hello @Jorz 

I have implemented it using query selector attaching an omlfor the same

Sample - Table Header values

I hope this helps
Thanks
Tousif Khan

SamplePOC_GetTableHeader.oml
2023-10-21 19-42-11
Tousif Khan
Champion

Hello,
is your table Mapped to an Entity?

If yes then you can easily get the col names by these tables

https://www.outsystems.com/forums/discussion/69478/display-entity-column-names-on-screen-in-dropdown/

If you want this through UI only then,
Check here - https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_td_headers

I hope this will help

Thanks
Tousif Khan

UserImage.jpg
Jorz

Thanks for your response. But i'm using the data table id instead of header id. My code is working on DevTools as you can see on below screenshot. How to apply this code using outsystems approach since I'm using input parameter for table ID and output parameter for the header label.

Thanks,

2023-10-21 19-42-11
Tousif Khan
Champion
Solution

Hello @Jorz 

I have implemented it using query selector attaching an omlfor the same

Sample - Table Header values

I hope this helps
Thanks
Tousif Khan

SamplePOC_GetTableHeader.oml
UserImage.jpg
Jorz
2024-01-04 15-15-51
Abed Al Banna

Hi @Jorz 

Try the following code:


var table = document.getElementById($parameters.Tbl_Id); 

var headerCells= table.getElementsByTagName("th"); 

var headerLabels = ""; 

for (var i = 0; i < headerCells.length; i++) {    

var label = headerCells[i].innerText;  

  headerLabels += label + " "; 

$parameters.Header = headerLabels;

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.