How we get RowHeader as TH element

Tags: #<Tag:0x00007efc71a344a8> #<Tag:0x00007efc71a34340>

from the previous question Custom UI for top left conner of table I can put the checkbox in the top left corner successfully. Thanks to @adrian.szymanski

The next problem I try to do is check all checkboxes inside rowHeaders if the checkbox inside the top left corner is checked.

My plan is I’ll get all checkboxes inside RowHeaders and set attribute to it as checked. but the problem is how I can get all TH elements inside rowHeaders in every rows, ideally I’d get only for row that is visible.

I tried to use getRowHeader method but it return only a string, not a DOM element so I can’t use it to retrieve the input checkbox.

the getCell seems can return element, but unfortunately, it unable to return rowHeader since it has check that col must be greater than or equal to 0, which it is only data cell.

So my question is how we can get TH element inside RowHeader?

Hi @elecwebmaker

I think this topic might be helpful with your case: Get rows with checkbox in rowHeader

There is a solution provided how to check the state of the checkboxes in the row header. In that case it is retrieved by invoking the logic on button click.

@adrian.szymanski

Thank you. but I have no problem with retrieving the state of the checkbox in the row header. My problem is I’d like to set all checkbox inside each row header to be checked if a user click checks all checkbox (in the top left corner). So my idea is trying to get all TH elements inside each row header and retrieve the checkbox input element, then set the attribute checked to it. Do you have any suggestions on how I can retrieve all row header TH elements?

@elecwebmaker

I see. I have an example that might be helpful here: https://jsfiddle.net/handsoncode/j7fgohq0/ Let me know if that meets your requirements.

Aww, got you. Thank you so much for your support @adrian.szymanski.

Just curious, how afterGetRowHeader can be triggered when we select check all checkbox? I thought afterGetRowHeader triggered only when the row was visible. As my understanding, it also run when we call setDataAtRowProp right ?

Yes, setDataAtRowProp basically changes the state of the input element in the row header as it alters it’s value depending on the main checkbox state.

Thank you for helping me. Hope you have a good day bro. :pray:

1 Like