gridjs icon indicating copy to clipboard operation
gridjs copied to clipboard

how to access different td from a click event on same row

Open mhanuel26 opened this issue 2 years ago • 3 comments

Hi all,

I have a table that I have setup for click event, it has an id column and a status column among others. I am responding to a click event on the id td element, and I want to get the value of the status column for that row (td element text), for example to do some decision that depens on its value using javascript code.

For instance, I know how to get the text of id as below

        tableDiv.addEventListener('click', ev => {
          if (ev.target.tagName === 'TD') {
            console.log(ev.target.dataset.columnId );
            if (ev.target.dataset.columnId == 'status'){
              window.location.href = '/logs';
            }else if(ev.target.dataset.columnId == 'id'){
              str = ev.target.textContent;
              alert("Press Ok for start blinking LED on device ID: " + str);
            }
          }
        });

Is there a way to access the status text value?

mhanuel26 avatar Aug 18 '22 15:08 mhanuel26

Hi @mhanuel26,

If I understand this correctly, you're trying to get the textContent of the cell clicked?

Could you share a code sandbox of the issue? That would help us tackle the issue faster.

aloysb avatar Aug 22 '22 22:08 aloysb

Hi @Aloysb ,

It is about getting the textContent of another td on that row, that is, the td clicked is not of interested but another td on that row.

Does this make sense?

mhanuel26 avatar Aug 23 '22 15:08 mhanuel26

Unfortunately no, I'm unsure I understand your issue. Can you clarify? It seems that this is not a gridjs related issue, but a DOM manipulation one?

aloysb avatar Aug 25 '22 11:08 aloysb

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 29 '22 00:10 stale[bot]