-
1. Re: extendedDataTable selection x 2nd click
michpetrov Oct 8, 2015 4:12 AM (in response to edilmar)Well, onselectionchange fires only if the selection changes. I'm assuming you rerender the table after you update the data, clear the selection when you do that.
-
2. Re: extendedDataTable selection x 2nd click
edilmar Oct 8, 2015 10:29 AM (in response to michpetrov)I did this to clear selection:
1) Method to update the row in the JSF controller called by "Gravar" (Save) button in the popupPanel:
private Collection<Object> selectionTableItemOS;
...
public String gravarItemOS() {
... logic to update data in the database ...
selectionTableItemOS.clear();
selectionTableItemOS = null;
return null;
}
2) Code to clear the selection in the xhtml popupPanel button:
<a4j:commandButton value="Gravar" action="#{ordemServicoComp.gravarItemOS}" render="table" execute="cadastrarItemOSPanel" oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('cadastrarItemOSPanel')}.hide();#{rich:component('table')}.setActiveRow(null);}" /> Then, the table becomes without row selected after the user clicks "Gravar" button, saves the data and returns to the main page.
The problem is that if I clicks again in the same row, no selection is made and the popupPanel is not opened. Just like before.
-
3. Re: extendedDataTable selection x 2nd click
edilmar Oct 8, 2015 10:39 AM (in response to edilmar)I got using this:
#{rich:component('table')}.deselectRow(#{rich:component('table')}.activeIndex);
-
4. Re: extendedDataTable selection x 2nd click
michpetrov Oct 8, 2015 11:31 AM (in response to edilmar)When you rerender the table and the row is unselected it should select the row again, if that doesn't happen the error is somewhere in the JavaScript.
This works fine for me:
<rich:extendedDataTable value="#{[1]}" selection="#{bean.selection}" var="i" id="table"> <rich:column>#{i}</rich:column> <a4j:ajax event="selectionchange" oncomplete="#{rich:component('panel')}.show()" /> </rich:extendedDataTable> <rich:popupPanel id="panel"> <a4j:commandButton action="#{bean.clearSelection()}" value="Clear and Close" render="table" oncomplete="#{rich:component('panel')}.hide();" /> </rich:popupPanel>
(bean.selection is an Object, clearSelection() sets it to null)