This solution aims to address several of the drawbacks of the original answer:
oncomplete="jQuery('.ui-datatable-data tr').last().find('span.ui-icon-pencil').each(function(){jQuery(this).click()});"
The above statement retrieves all the "tr" elements that are descendants (at any level) of elements with the class .ui-datatable-data. Possible problems with this:
- As @Gnappuraz mentioned, if a document has several p: datatable, this statement will select the last table.
- Also, I had a problem where even with one datatable column with the p component: selectOneRadio also displays an html table (containing the "tr" elements). In this case, the selector selects the last "tr" for the p: selectOneRadio table, and not for p: datatable.
- Not a problem, but the instruction can be shortened to exclude each () due to jQuery implicit iteration .
What I ended up with:
oncomplete="jQuery('#tableForm\\:table .ui-datatable-data > tr').last().find('span.ui-icon-pencil').click();"
This selector says - get the last element "tr", which is the direct child of the element with the class .ui-datatable-data, which is also a descendant of the element with id "table" in the form of "tableForm". In other words, now you can have several p: datatables, and any of them include any components that display html tables.
jdessey
source share