Can you explain how to retrieve the header value from ng-table?

Is there a way to retrieve the table header for each column from JavaScript? When I call tableTest, it only returns data of each row, not the header names like 'name' and 'description'. Is there a method like tableTest.data-title to access this information?

<table ng-table="tableTest">
  <tbody>
    <tr ng-repeat="sample in $data">
      <td data-title="'Name'" sortable="'name'">
          {{sample.name}}
      </td>
      <td data-title="'Description'" sortable="'description'">
          {{sample.description}}
      </td>
    </tr>
  </tbody>
</table>

Any help is appreciated. Thank you!

Answer №1

Have you considered utilizing JavaScript for this task?

Check out the code snippet on Plunker

HTML

<table ng-table="tableParams" id="myTable">
    <tbody>
        <tr ng-repeat="sample in $data">
            <td data-title="'Name'" sortable="'name'">
                {{sample.title}}
            </td>
            <td data-title="'Description'" sortable="'description'">
                {{sample.description}}
            </td>
        </tr>
    </tbody>
</table>

<script>
    // Accessing the table
    var oTable = document.getElementById('myTable');

    // Getting the number of rows
    var rowLength = oTable.rows.length;

    // Iterating through each row    
    for (i = 0; i < rowLength; i++) {

        // Accessing cells of current row  
        var oCells = oTable.rows.item(i).cells;

        // Getting the number of cells in current row
        var cellLength = oCells.length;

        // Iterating through each cell in current row
        for (var j = 0; j < cellLength; j++) {

            // Get cell information here

            var cellTitle = oCells.item(j).getAttribute("data-title");
            document.write("Header for Row#" + j + " : " + cellTitle + "<br>");
        }
    }
</script>

Output

Header for Row#0 : 'Name'
Header for Row#1 : 'Description'

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Showing data from a MySql database using an HTML table

I am currently working on a pop-up form that captures user data and stores it in a MySQL phpmyadmin table. My goal is to have this data displayed in an HTML table once the popup form is closed. After submitting the form, I am redirected back to the homepag ...

What is the process for attaching an event handler to an element that is displayed after a button click?

I need some assistance with my JavaScript code. I have a page with two links, and when the second link is clicked, certain fields are displayed. I am trying to write an onkeyup() event handler for one of these fields, but seem to be missing something. Here ...

The .map() operator requires a declaration or statement to be specified - TS1128 error

I've tried various solutions from different sources but none seem to be resolving the issue I'm facing. The problem is: when trying to run my app, I encounter the following error: 10% building modules 0/1 modules 1 active …\src\a ...

When utilizing $state.go(), the resolve promise of a parent state is not executed by ui-router

My issue involves an abstract parent state containing a resolve promise that fetches information about the current user. This data is then injected into controllers of all child states. The problem arises when I try to navigate using $state.go('paren ...

Is there a problem with how the public directory is currently configured?

Recently, I completed a Webpack project and organized it in the following structure: static/ // Contains js and css files index.html // Main file I decided to integrate this setup into an Express environment by placing it inside the public/ folder. Here& ...

Ways to navigate to a new webpage in JavaScript without the need to click on a link

After going through various posts and trying different methods, I am still facing challenges. In a PHP page, I have an HTML form with an onClick command that triggers a JavaScript validation procedure when the user clicks a button. While everything funct ...

Tips for adjusting font size automatically to fit within its parent container every time

On my blog, the post titles are displayed in a div with a video playing in the background. The length of the title varies, ranging from 2 words to over 20 words. When the title is too long, it may overflow from its parent container where the video is playi ...

Notification for background processing of $http requests

I am searching for a solution to encapsulate all my AJAX requests using $http with the capability to display a loading gif image during processing. I want this functionality to extend beyond just $http requests, to cover other background processing tasks a ...

Deactivate buttons: saving data exclusively for the most recent click

My application has a series of buttons, each representing a channel. When a button is clicked, it triggers a function in the MainController with the corresponding ID as a parameter. Next to the channel buttons, there is an input field where I can enter in ...

Using a JSON object in HTML directive with AngularJS conditional statement

Having a JSON object that looks like this: { filters: [ {Name: "pork", Active: true}, {Name: "beef", Active: true}, {Name: "chicken", Active: false} ] } An intention to create a SELECT list with th ...

Utilizing the jQuery slideToggle method on the specified target element

I'm encountering an issue with jQuery slideToggle, and here's the code I have: $(".dropdownmainmenu").click(function(){ $(this).children(".showmenu").slideToggle(); $(this).toggleClass("activemainmenu"); $(this).find(".showarrowmainmen ...

A step-by-step guide on extracting nested ASP.NET DataGrid values with JavaScript

Looking to retrieve data from a nested data grid on an aspx page using JavaScript. Check out the following code snippet: <tr> <td colspan="2" align="center"> <asp:DataGrid ID="sampleData" AutoGenerateColumns="false" runat="serv ...

Deciphering the mechanics of collection referencing in mongoose

Today, I am delving into the world of using references in mongoose for the first time. I am trying to figure out how to save a template with a user ID. Do we need to retrieve the createdBy value from the client, or can it be inserted into the templateSchem ...

The DiscordBot is configured to send a personalized direct message to users who have chosen a specific role

Having trouble setting up my bot to send a DM to new members who choose the Advertising role, and I can't figure out why. I'm fairly new to this. const { Client, GatewayIntentBits } = require('discord.js'); const client = new Client({ ...

Can a webpage be sent to a particular Chromecast device without using the extension through programming?

My organization has strategically placed multiple Chromecasts across our facility, each dedicated to displaying a different webpage based on its location. Within my database, I maintain a record of the Chromecast names and their corresponding URLs. These d ...

Is there a way to compare the elements of an array with those of another array containing nested arrays in order to identify matching results?

Every user in our database has specific skills assigned to them. We maintain a list of available skills with unique IDs. The objective is to filter users based on the skill we are interested in, like displaying all Janitors. We are utilizing Vue.js and im ...

Increase the count for each category with the help of JavaScript

Currently, I am working on an application using PHP and have 180 vendors registered in the database. Each vendor has a unique ID stored in the database. I need to create a system where every time a user clicks on the "view details" button for a specific ...

Tips on avoiding blurring when making an autocomplete selection

I am currently working on a project to develop an asset tracker that showcases assets in a table format. One of the features I am implementing is the ability for users to check out assets and have an input field populated with the name of the person author ...

The search and sorting functionality in jquery DataTables is malfunctioning

I am facing difficulties with sorting and filtering the datatable as none of the JS functions seem to be working properly. I have already included the necessary JS files. Here are some details: I am connecting to a database to retrieve data in JSON format. ...

Creating a complete webpage using HTML

Is there a method to load an HTML file and execute the embedded javascript to create a complete HTML page programmatically similar to how browsers do? Edit 1 - I am working on an application where I need to extract data from an HTML page on a remote websi ...