gridjs
gridjs copied to clipboard
how to access different td from a click event on same row
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?
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.
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?
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?
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.