Reputation: 552
I have multiple datatables whose are in single selection mode. I know how many datatables I have and how to reference to them because I append an index to their widgetVar attribute. So I can reference them by the "non-safe" operation var dt = eval('dt' + index)
.
The issue I am facing is every time I select a row in one of the nested dataTables the selection is remaining on the other ones and I want to clean them.
I've tried something like:
<p:ajax event="rowSelect" onstart="deseleccionarTablas()"/>
function deseleccionarTablas()
{
for (i=0; i < dtEstacionesSeleccionadas.getPaginator().cfg.rows; i++)
{
var dt = eval('dt' + i);
dt.unselectAllRows();
}
};
dtEstacionesSeleccionadas is the "container" or "root" table and works in "lazy" mode with paginator, so a variable number of nested dataTables may be shown. The code above doesn't work because it unselects everything, even the last row I selected, as expected. And I want that last one to remain selected.
Any ideas? Thank you.
Upvotes: 0
Views: 295
Reputation: 9266
Instead of using JavaScript, why don't you update them on the server side? Each table should have the selection="#{mrBean.selectedRow}"
attribute. You only need to set all of those things to null
in the actionListener
of the <p:ajax event="rowSelect">
. Then, a simple update="table1 table2 ... tablen"
will solve you problem.
Upvotes: 1