Wt::WTableRow::jsRef ?

Added by lm at almost 2 years ago

It looks like Wt::WTableRow does not have a jsRef member function: jsRef is defined on Wt::WWebWidget: I guess Wt::WTableRow is not Wt::WebWidget (perhaps because it, itself, is not usually visible to the end user?), but it certainly should have a jsRef()...maybe I'm missing it?

In my case, I'm wanting to make a row appear like this: This requires adding a row with class row-collapsed, then doing

doJavaScript("setTimeout(()=>" + new_row->jsRef() + ".className = 'row-expand', 1);"};

or so. In other words, I need a javascript reference to my row so that I can change its class name, but there is no jsRef member function on the row.

Replies (2)

RE: Wt::WTableRow::jsRef ? - Added by Roel Standaert almost 2 years ago

Yeah, WTableRow itself isn't a widget. A jsRef() may be useful, but for now you could work around it by either:

  • Taking the jsRef() of a WTableCell and moving up the DOM to the <tr> element: cell.jsRef() + ".parentElement"
  • Taking the n-th row in the table: table.jsRef() + ".querySelector(':scope > tbody > tr:nth-child(n)')" (with n starting from 1), or table.jsRef() + ".querySelectorAll(':scope > tbody > tr')[n]" (with n starting from 0)

RE: Wt::WTableRow::jsRef ? - Added by lm at almost 2 years ago

Thank you!