p:columnToggler and update on datatable

UI Components for JSF
Post Reply
lmessmer
Posts: 10
Joined: 21 Nov 2011, 14:26

30 Sep 2016, 09:32

Hi all

I'm using the p:columnToggler as follow:

Code: Select all

<p:dataTable id="resultDataTable" var="dto" value="#{fctMainController.dtos}" paginator="true" 
         paginatorPosition="top" rows="20" scrollHeight="#{fctMainController.scrollHeight}" scrollable="true"
         currentPageReportTemplate="#{msg['all.label.currentPageReportTemplate']}" 
         paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {MyContent}" 
	rowsPerPageTemplate="20,50,100,250,#{msg['all.label.all']}" emptyMessage="#{msg['all.label.noDataFound']}"
        widgetVar="resultDataTableVar"
	tableStyle="table-layout:fix;width:100%;" draggableColumns="true" resizableColumns="true">

	<f:facet name="{MyContent}">
	   <p:commandButton id="toggler" type="button" icon="ui-icon-calculator" />
	   <p:columnToggler datasource="resultDataTable" trigger="toggler" id="resultDataTableToggler">
		   <p:ajax event="toggle" listener="#{fctMainController.onToggle}" oncomplete="fixDatatableScrollPaneHeight();" />
	   </p:columnToggler>
	</f:facet>
		
	<p:ajax event="colReorder" listener="#{fctMainController.onReorder}"/>
	<p:ajax event="colResize" listener="#{fctMainController.onResize}"/>

	<p:ajax event="page" onstart="loadPage()" oncomplete="loadPageDone()" />
	<p:ajax event="sort" onstart="loadPage()" oncomplete="loadPageDone()" />

	<p:column id="tab1_pn" styleClass="align_left" sortBy="#{dto.userId}" headerText="#{msg['all.label.pn']}" toggleable="false" width="50">
		<h:outputText value="#{dto.userId}"/>
	</p:column>
	<p:column id="tab1_userName" styleClass="align_left" headerText="#{msg['all.label.employee']}" sortBy="#{dto.userName}"  
                      visible="#{fctMainController.isColVisible(1)}">
		<h:outputText value="#{dto.userName}"/>
	</p:column>
	<p:column id="tab1_homeNode" styleClass="align_left" headerText="#{sessionUtil.shopHeaderText}" sortBy="#{dto.homeNode.id}" 
                       visible="#{sessionUtil.shopSelectRendered and fctMainController.isColVisible(2)}" toggleable="#{sessionUtil.shopSelectRendered}">
		<h:outputText converter="#{shopNameConverter}" value="#{dto.homeNode}"/>
	</p:column>
	<p:column id="tab1_date" styleClass="align_left valign_middle" headerText="#{msg['all.label.date']}" sortBy="#{dto.calendarDate}"
                    toggleable="false" width="105">
		<h:outputText value="#{dto.calendarDate}" style="font-family: courier new;">
			<f:convertDateTime pattern="EEE " timeZone="CET"/>
		</h:outputText>
		<h:outputText value="#{dto.calendarDate}" >
			<f:convertDateTime pattern="dd.MM.yyyy" timeZone="CET"/>
		</h:outputText>
	</p:column>

	<p:column id="tab1_absenceType" styleClass="align_left" headerText="#{msg['all.label.absenceType']}" sortBy="#{dto.absenceTypeForSort}"
                  toggleable="false">
		<h:outputText converter="#{absenceTypeCodeTextConverter}" value="#{dto.absenceType}" style="vertical-align:middle;"/>
	</p:column>

	<p:column id="tab1_halfDayType" styleClass="align_left" headerText="#{msg['pla503.label.halfDayType']}" sortBy="#{dto.halfDayTypeStr}" 
                    width="80" visible="#{fctMainController.isColVisible(5)}">
		<h:outputText converter="#{codeTextConverter}" value="#{dto.halfDayTypeStr}" />
	</p:column>

	<p:column id="tab1_timeValue" styleClass="align_left" headerText="#{msg['pla503.label.timeValue']}" sortBy="#{dto.timeValue}" 
                      rendered="#{fctMainController.showTimeValue}" visible="#{fctMainController.isColVisible(6)}" width="80">
		<h:outputText value="#{dto.timeValueAsTime}" converter="#{timeConverter}" />
	</p:column>

	<p:column id="tab1_timeFrom" styleClass="align_left" sortBy="#{dto.timeFrom}" headerText="#{msg['all.label.timeFrom']}" 
                     rendered="#{fctMainController.showTimeValue}" visible="#{fctMainController.isColVisible(7)}" width="80">
		<h:outputText value="#{dto.timeFrom}" >
			<f:convertDateTime pattern="HH:mm" timeZone="CET" locale="de_CH"/>
		</h:outputText>
	</p:column>
	<p:column id="tab1_timeTo" styleClass="align_left" sortBy="#{dto.timeTo}" headerText="#{msg['all.label.timeTo']}" 
                        rendered="#{fctMainController.showTimeValue}" visible="#{fctMainController.isColVisible(8)}" width="80">
		<h:outputText value="#{dto.timeTo}" >
			<f:convertDateTime pattern="HH:mm" timeZone="CET" locale="de_CH"/>
		</h:outputText>
	</p:column>

	<p:column id="tab1_pk" styleClass="align_left" headerText="#{msg['all.label.pk']}" sortBy="#{dto.pk}" visible="#{fctMainController.isColVisible(9)}">
		<h:outputText value="#{dto.pk}"/>
	</p:column>

	<p:column id="tab1_serial" styleClass="align_left" width="20" toggleable="false">
		<h:graphicImage id="planOpenIcon" url="#{stylesheetManager.imageDir}serie.png" alt="#{msg['all.label.serie']}" title="#{msg['all.label.serie']}" 
				style="border:none;vertical-align:middle;" rendered="#{dto.domainObject.userAbsenceDefinition != null}"/>
	</p:column>

	<p:column id="tab1_action" styleClass="align_left" headerText="#{msg['all.label.action']}" rendered="#{fctMainController.writeAccess}" 
                   wxportable="false" toggleable="false" width="100">
		<p:commandLink id="editAbsence" title="#{dto.editableMsg}" disabled="#{!dto.editable}" oncomplete="saveScrollPos();PF('crudDialog').show()" update=":crudFormModal">
			<h:graphicImage id="editIcon" url="#{stylesheetManager.imageDir}edit.png" alt="#{dto.editableMsg}" title="#{dto.editableMsg}" style="border:none;"/>
			<f:setPropertyActionListener value="#{dto}" target="#{fctMainController.editSelectedDto}" />
			<f:param name="skipvalidation" value="1" />
		</p:commandLink>
		&#160;
		<p:commandLink id="copyAbsence" title="#{dto.copyableMsg}" disabled="#{!dto.copyable}" oncomplete="saveScrollPos();PF('crudDialog').show()" update=":crudFormModal">
			<h:graphicImage id="copyIcon" url="#{stylesheetManager.imageDir}copy.png" alt="#{dto.copyableMsg}" title="#{dto.copyableMsg}" style="border:none;"/>
			<f:setPropertyActionListener value="#{dto}" target="#{fctMainController.copySelectedDto}"/>
			<f:param name="skipvalidation" value="1" />
		</p:commandLink>
		&#160;
		<p:commandLink id="deleteAbsence" title="#{dto.deletableMsg}" disabled="#{!dto.deletable}" onclick="saveScrollPos();PF('deleteConfirmation').show()">
			<h:graphicImage id="deleteIcon" url="#{stylesheetManager.imageDir}delete.png" alt="#{dto.deletableMsg}" title="#{dto.deletableMsg}" style="border:none;"/>
			<f:setPropertyActionListener value="#{dto}" target="#{fctMainController.deleteSelectedDto}" />
		</p:commandLink>
	</p:column>
</p:dataTable>
With the debugger, I notice that by update on the table, there are more and more <div class="ui-columntoggler ui-widget ui-widget-content ui-shadow ui-corner-all" id="resultDataTable:resultDataTableToggler" role="dialog"> in the DOM.

so after page load:
one such div

after each subsequent update 1 or 2 more div. And so on.

When I open the columnToggler check/uncheck columns and perform an update on the dataTable having the columnToggler opened, I can't close the columnToggler anymore. It remains open forever. I think that this problem is correlated to the multiple <di> elements.

How can I solve this problem?

Thanks,
Luc
PF Elite 6.0.3, Tomcat, JSF 2.2, Spring 3.2, Hibernate 4.2.16

arieuqis
Posts: 1
Joined: 09 May 2017, 16:08

09 May 2017, 16:19

Hi Luc!

Have you solved this problem? I'm facing the same behavior trying to update the datatable after the toggle event.
The datatable updates perfectly, but the column toggler doesn't hide.
I've tried to call PF('toggler').hide() on oncomplete, but it's not working for me.

Bruno
Best regards,

Bruno

bmoon
Posts: 24
Joined: 10 May 2016, 21:16

23 May 2017, 21:09

I have a similar issue. I have a columnToggler that I use an ajax event to save away the column's as they are closed and this causes an update to the content of the page. When the update happens, then I can't close the columnToggler any more until I do a complete page reload.

I can confirm the same behavior as the first poster, each time I click on a column to "toggle" the a new "div" is added to my document with a new columnToggler attached.

Here's my code:

Code: Select all

                        <p:dataTable id="table" var="gts" value="#{sessionBean.tableContent}" reflow="true" sortMode="multiple" draggableColumns="true"
                                     paginator="true" rows="100" style="margin-bottom:20px;" paginatorPosition="Bottom">
                            <f:facet name="header">
                                <h:outputLabel value="#{sessionBean.selectedAnalytic.name}" style="font-size:large;"/>
                                <p:spacer height="30px"/>
                                <span style="float:right; margin-right: 5px;">
                                    <p:commandButton id="toggler" type="button" icon="ui-icon-view-column" title="Select columns to display." />
                                    <p:spacer width="12px"/>
                                    <p:commandButton icon="ui-icon-file-download" ajax="false">
                                        <p:dataExporter type="xls" target="table" fileName="#{sessionBean.selectedAnalytic.name}" options="#{sessionBean.excelOptions}"/>
                                    </p:commandButton>
                                </span>
                                <p:columnToggler datasource="table" trigger="toggler">
                                    <p:ajax event="toggle" listener="#{sessionBean.onAnalyticToggle}"/>
                                </p:columnToggler>
                            </f:facet>
                            <p:columns value="#{sessionBean.seriesNames}" var="column" sortBy="#{gts.get(sessionBean.getSeriesIndex(column))}" visible="#{sessionBean.isAnalyticColumnVisible(column)}">
                                <f:facet name="header">
                                    <h:outputLabel value="#{column}"/>
                                </f:facet>
                                <h:outputText value="#{gts.get(sessionBean.getSeriesIndex(column))}"/>
                            </p:columns>
                        </p:dataTable>
Here's the document after page load:

Code: Select all

<div id="contentForm:table:j_idt210" role="dialog" class="ui-columntoggler ui-widget ui-widget-content ui-shadow ui-corner-all" style=""><a href="#" class="ui-columntoggler-close" aria-label="Close"><span class="ui-icon ui-icon-close"></span></a><ul class="ui-columntoggler-items" role="group"><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" aria-checked="true" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active"><span class="ui-chkbox-icon ui-icon ui-icon-check"></span></div></div><label>Time</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" aria-checked="true" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active"><span class="ui-chkbox-icon ui-icon ui-icon-check"></span></div></div><label>Latitude</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default"><span class="ui-chkbox-icon ui-icon ui-icon-blank"></span></div></div><label>Longitude</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default"><span class="ui-chkbox-icon ui-icon ui-icon-blank"></span></div></div><label>Elevation</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" aria-checked="true" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active"><span class="ui-chkbox-icon ui-icon ui-icon-check"></span></div></div><label>Origin</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" aria-checked="true" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active"><span class="ui-chkbox-icon ui-icon ui-icon-check"></span></div></div><label>Level</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" aria-checked="true" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active"><span class="ui-chkbox-icon ui-icon ui-icon-check"></span></div></div><label>Value</label></li></ul></div>
Now, after I've opened the toggle and selected a single item I get the following, note that a second DIV is added just after the "contentForm:table" original div. The second div is another toggle :???

Code: Select all

<div id="contentForm:table:j_idt210" role="dialog" class="ui-columntoggler ui-widget ui-widget-content ui-shadow ui-corner-all" style="z-index: 1001; top: 149px; left: 1298.2px; display: block;"><a href="#" class="ui-columntoggler-close" aria-label="Close"><span class="ui-icon ui-icon-close"></span></a><ul class="ui-columntoggler-items" role="group"><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" aria-checked="true" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active"><span class="ui-chkbox-icon ui-icon ui-icon-check"></span></div></div><label>Time</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" aria-checked="false" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default"><span class="ui-chkbox-icon ui-icon ui-icon-blank"></span></div></div><label>Latitude</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default"><span class="ui-chkbox-icon ui-icon ui-icon-blank"></span></div></div><label>Longitude</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default"><span class="ui-chkbox-icon ui-icon ui-icon-blank"></span></div></div><label>Elevation</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" aria-checked="true" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active"><span class="ui-chkbox-icon ui-icon ui-icon-check"></span></div></div><label>Origin</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" aria-checked="true" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active"><span class="ui-chkbox-icon ui-icon ui-icon-check"></span></div></div><label>Level</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" aria-checked="true" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active"><span class="ui-chkbox-icon ui-icon ui-icon-check"></span></div></div><label>Value</label></li></ul></div>
<div id="contentForm:table:j_idt210" role="dialog" class="ui-columntoggler ui-widget ui-widget-content ui-shadow ui-corner-all" style=""><a href="#" class="ui-columntoggler-close" aria-label="Close"><span class="ui-icon ui-icon-close"></span></a><ul class="ui-columntoggler-items" role="group"><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" aria-checked="true" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active"><span class="ui-chkbox-icon ui-icon ui-icon-check"></span></div></div><label>Time</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default"><span class="ui-chkbox-icon ui-icon ui-icon-blank"></span></div></div><label>Latitude</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default"><span class="ui-chkbox-icon ui-icon ui-icon-blank"></span></div></div><label>Longitude</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default"><span class="ui-chkbox-icon ui-icon ui-icon-blank"></span></div></div><label>Elevation</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" aria-checked="true" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active"><span class="ui-chkbox-icon ui-icon ui-icon-check"></span></div></div><label>Origin</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" aria-checked="true" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active"><span class="ui-chkbox-icon ui-icon ui-icon-check"></span></div></div><label>Level</label></li><li class="ui-columntoggler-item"><div class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input role="checkbox" aria-checked="true" type="checkbox"></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active"><span class="ui-chkbox-icon ui-icon ui-icon-check"></span></div></div><label>Value</label></li></ul><div></div></div>

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 55 guests