Display line numbers in HTML/CSS cellsorIncor

Attempting to include row numbers in HTML/CSS.

Below is the HTML code with React populating the rows:

<table className="table table-striped">
            <thead>
              <tr>
                {/*<th>ID</th>*/}
                <th>symbol</th>
                <th>close</th>
                <th>percent</th>
                <th>PE</th>
                <th>Rake</th>
                <th />
              </tr>
              </thead>
              <tbody>
                { this.props.item_sett_list.map(item_sett_list_item => (
                  <tr key={item_sett_list_item.id}>
                    {/*<td>{item_sett_list_item.id}</td>*/}
                    <td>{item_sett_list_item.symbol}</td>
                    <td>{item_sett_list_item.close}</td>
                    <td>{item_sett_list_item.percent}</td>
                    <td>{item_sett_list_item.pe}</td>
                    {
                      this.props.rake_sett_list.length ? 
                      this.props.rake_sett_list.map(rake_sett_list_item => (
                        <td>{rake_sett_list_item.rake}</td> 
                      )) : <td><a href="#/rakesetting"><button className='btn btn-primary btn-sm'>RAKE</button></a></td>
                      
                    }
                    <td><button onClick={this.props.deleteDCASettings.bind(this, item_sett_list_item.id)}className='btn btn-danger btn-sm'>Delete</button></td>
                  </tr>
                )) }
              </tbody>
          </table>

Attempted using custom.css as suggested in this solution:

The custom.css file loads successfully, and custom properties are visible in other elements. However, the rows do not display row numbers.

Answer №1

What if we utilize map indexes in our code:

           { this.props.item_sett_list.map((item_sett_list_item, index) => (
              <tr key={item_sett_list_item.id}>
                {/*<td>{index}</td>*/}
                <td>{item_sett_list_item.symbol}</td>
                <td>{item_sett_list_item.close}</td>
                <td>{item_sett_list_item.percent}</td>
                <td>{item_sett_list_item.pe}</td>
                {
                  this.props.rake_sett_list.length ? 
                  this.props.rake_sett_list.map(rake_sett_list_item => (
                    <td>{rake_sett_list_item.rake}</td> 
                  )) : <td><a href="#/rakesetting"><button className='btn btn-primary btn-sm'>RAKE</button></a></td>
                  
                }
                <td><button onClick={this.props.deleteDCASettings.bind(this, item_sett_list_item.id)}className='btn btn-danger btn-sm'>Delete</button></td>
              </tr>
            )) }

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

What steps should I follow to generate a table using Ajax and Javascript when a button is clicked?

After spending hours following various tutorials and exploring previously asked questions, I am struggling to make this work. My HTML page looks like this: <!DOCTYPE html> <html> <head> <link type="text/css" rel="styleshee ...

Text overlapping image causing hover state interference

I'm feeling completely lost right now. My goal is to have the title of each project displayed in the center of the screen when you hover over the respective project images. I've resorted to using jQuery for this because it seems like the most str ...

How can you align an icon to the right in a Bootstrap4 navbar while keeping it separate from the toggle menu?

Looking to utilize the Twitter Bootstrap framework for structuring my navbar with distinct "left", "middle", and "right" sections, where the middle portion collapses beneath the navbar-toggler (burger menu) when space is limited. For a self-contained exam ...

Generate gzipped files using Angular CLI

I am attempting to populate a dist folder with the standard files along with their .gz versions. To achieve this, I used ng eject to obtain the webpack.config.js file in order to integrate the compression plugin from https://github.com/webpack-contrib/comp ...

Selection of a map in React Native using a checkbox

When mapping through an array of objects called abilities in React Native that I retrieve from the backend, I am trying to individually select each one of them. However, when I select one checkbox, it selects all of them. How can I effectively select a s ...

The various options in the dropdown menu are descending in order

I am currently facing an issue with a dropdown menu that contains the list of products offered by our company. Specifically, one of the product names, Hotel Management Solutions, is appearing on multiple lines instead of a single line in the dropdown menu. ...

React - Clearing State data retrieved from axios request

I am currently facing an issue with resetting the state of an object in my users array upon clicking the delete button. Even after successfully removing the object from the database, the state does not update as intended. I have managed to verify the prese ...

Is there a way to adjust the size of a video thumbnail to fit within a

Currently, I am developing a system to remotely control home electrical devices via the web. However, I am facing an issue with fitting camera images properly within their container. How can I ensure that the video thumbnail fits perfectly in the designat ...

Revise this phrase: "Update MongoDB field information."

Can anyone help me figure out how to update a user's balance in the database table after a transfer? I've been trying to retrieve the balance but it keeps showing as empty, making it difficult for me to write the findAndUpdate code. Here is what ...

Tips for creating a div that slides from the right side to the left side

I received a code from someone and I need help with making the sliding div slide from right to left. Essentially, I want the div to hide on the right side and slowly move to the left within a width of 300px. Here is the HTML code: <a id="loginPanel"&g ...

What could be causing my website to function flawlessly in Firefox but not in Chrome or Internet Explorer?

Hey everyone, I'm feeling lost and have been comparing files using DiffNow. I don't have any code to offer because I'm unsure of where to even begin. The website is coded in php/html/mysql/jquery. Here are my main concerns: -Animations are ...

Having trouble getting JSX to compile while running tests with Jasmine and PhantomJS

When attempting to write a test that includes a rendering of a component using react/jasmine/phantomjs, I encountered an issue. My approach was as follows: beforeEach(function(){ var component = TestUtils.renderIntoDocument( <JsonTab ...

Displaying a base64 image in a new tab with JavaScript on iOS devices

Currently, I am receiving base64 data for an image and would like to open it in a new tab. To achieve this, my code looks something like this: var window = new window(); window.open("<iframe src="+base64Url+"); Interestingly, this method works perfec ...

When the user clicks, show a designated search result in a separate container

I've been developing my Angular cocktail application, and I've reached a point where I can display all the cocktails in my database (only showing names). Now, I want to implement a feature where if I click on a specific cocktail, its full content ...

When a Vue.js datepicker is set as required, it can be submitted even if

When using the vuejs-datepicker, setting the html required attribute on input fields may not work as expected. This can lead to the form being submitted without an input value. <form> <datepicker placeholder="Select Date" required></datep ...

I prefer to have the links activate when the mouse hovers over them, rather than when hovering over empty

Is there a way to prevent the bottom links (music, contact, archive) from being highlighted when the mouse hovers over the empty space between them and not just on the actual links themselves? I want the mouse to only react to the links it hovers over and ...

The Material-ui toolbar is displaying unexpected results and not showing the desired output

I'm attempting to set up the toolbar using material-ui based on the documentation provided. My toolbar.js file appears as follows: import React from 'react'; import IconMenu from 'material-ui/IconMenu'; import IconButton from &ap ...

I'm struggling to understand how to use the Beautifulsoup find() function with this particular HTML code

I have been attempting to extract specific information from a webpage using Python and Beautiful Soup, but I am struggling to correctly identify the path to the data I need. Here is an example of the HTML code: <div class="operator active" data-operato ...

The content in the flex box item with horizontal scroll is overflowing beyond its boundaries

I am working with a flex box container that contains two child elements: a left side and a right side. I want the right side item to have a horizontal scrollbar in order to fit its content. .container { display: flex; overflow: hidden; height: 300 ...

The information retrieved through the fetch API is not displaying on connected devices

I am currently in the process of learning React and am using the Fetch API. I have successfully fetched data and displayed it on my local computer. However, when previewing it on my mobile device connected to the same network, the fetched data is not showi ...