I'm trying to put a scrollable datatable inside of a rowExpansion tag, but the resulting datatable comes out all weird, like this:
Code:
<p:rowExpansion>
<h:panelGrid id="display" columns="2" cellpadding="4"
styleClass="ui-widget-content"
columnClasses="label, value">
<h:outputText value="Registrerad:"/>
<h:outputText id="registered" value="#{campaignOfferGroupView.formatDate(offerGroup.registerDate)}"/>
<h:outputText value="Senast ändrad:"/>
<h:outputText id="changeDate" value="#{campaignOfferGroupView.formatDate(offerGroup.changeDate)}"/>
<h:outputText value="Ändrad av:"/>
<h:outputText id="changedBy" value="#{offerGroup.changedBy}"/>
</h:panelGrid>
<p:dataTable var="campaignCode" value="#{campaignOfferGroupView.getCampaignCodesForGroup(offerGroup.id)}"
scrollable="true" scrollHeight="120">
<f:facet name="header">
Kampanjkoder tillhörande kampanjerbjudandegruppen
</f:facet>
<p:column headerText="ID">
#{campaignCode.id}
</p:column>
<p:column headerText="Namn">
#{campaignCode.description}
</p:column>
<p:column headerText="Start">
#{campaignCode.startDate}
</p:column>
<p:column headerText="Stop">
#{campaignCode.stopDate}
</p:column>
</p:dataTable>
Anyone have any idea why this is? If I remove the scrollable attribute the table looks fine:
Incidentally, is there any way to remove the grey empty column created by a scrollable DataTable as seen in http://www.primefaces.org/showcase/ui/datatableScrolling.jsf?
EDIT: I have noticed that the ShowCase has column size fixed using the style attribute. I would rather avoid this if possible.
Related
So, I've used example from showcase of PrimeFaces https://www.primefaces.org/showcase/ui/dnd/dataTable.xhtml. That's my code:
<div class="page_content">
<div class="header">Очередь рассылок</div>
<script type="text/javascript">
function handleDrop(event, ui) {
var droppedEmail = ui.draggable;
droppedEmail.fadeOut('fast');
}
</script>
<h:form>
<p:fieldset id="availableEmailsField" legend="Доступные рассылки">
<p:dataTable id="availableEmails" var="email" value="#{emailingQueueUI.customEmails}">
<p:column style="width: 20px;">
<h:outputText id="dragIcon" styleClass="ui-icon ui-icon-arrow-4"/>
<p:draggable for="dragIcon" revert="true" helper="clone"/>
</p:column>
<p:column headerText="ID">
<h:outputText value="#{email.id}"/>
</p:column>
<p:column headerText="Название">
<h:outputText value="#{email.name}"/>
</p:column>
<p:column headerText="Заголовок">
<h:outputText value="#{email.header}"/>
</p:column>
<p:column headerText="Количество порции">
<h:outputText value="#{email.chunkSize}"/>
</p:column>
</p:dataTable>
</p:fieldset>
<p:outputPanel id="selectedEmailsField">
<p:outputPanel id="dropArea">
<h:outputText value="Переместите сюда c доступных рассылок" rendered="#{empty emailingQueueUI.customEmailQueue}" style="font-size:16px;" />
<p:dataTable id="selectedEmails" var="email" value="#{emailingQueueUI.customEmailQueue}" rendered="#{not empty emailingQueueUI.customEmailQueue}"
rowIndexVar="index">
<!--<p:ajax event="rowReorder" listener="#{emailingQueueUI.onQueueReorder}" update=":form" />-->
<p:column headerText="Номер в очереди">
<h:outputText value="#{index}"/>
</p:column>
<p:column headerText="Рассылка">
<h:outputText value="#{email.id}"/>
</p:column>
<p:column headerText="Название">
<h:outputText value="#{email.name}"/>
</p:column>
<p:column headerText="Заголовок">
<h:outputText value="#{email.header}"/>
</p:column>
<p:column headerText="Количество порции">
<h:outputText value="#{email.chunkSize}"/>
</p:column>
</p:dataTable>
</p:outputPanel>
</p:outputPanel>
<p:droppable for="selectedEmailsField" tolerance="touch" activeStyleClass="ui-state-highlight" datasource="availableEmails" onDrop="handleDrop">
<p:ajax listener="#{emailingQueueUI.onEmailDrop}" update="dropArea availableEmails" />
</p:droppable>
</h:form>
</div>
There is a problem with d&d, I can drag and drop only one element from "availableEmailsField". When I try to drop another element it removes previous element and adds the dropped one.
I think the problem is in your bean.
Make sure that you initialize customEmailQueue inside #PostConstruct method and use the proper bean scope. In this case #ViewScoped.
It seems that an update function must be setted correctly in order to work properly. I faced the same issue and discovered that the ajax inside dropable has to update all drag-drop area elements, it seems that this action solves the issue.
The solution that worked is to put inside your form an:
<h:panelGroup id="elementsPanel">
....
...
...
...
....
</h:panelGroup>
, surrounding all drag-drop elements (if you dont want a panelgroup the idea is to update all the components)
and on the dropable update this panel:
<p:droppable id="dropHandler" for="selectedTable" tolerance="touch" activeStyleClass="ui-state-highlight" datasource="myDataSource" onDrop="handleDrop">
<p:ajax listener="#{dimensionsClass.onDimensionDrop2}" update="elementsPanel" />
</p:droppable>
I hope that helps!
I am not sure if it is supported as I cannot make the fileUploadListener working in the subTable. Only the basic file upload demo works in the nested table. Seems like the FileUploadEvent is not called. Upload progress bar shows and disappears but the listener method is not fired.
<p:dataTable var="parent" value="#{bean.parents}">
<p:columnGroup type="header">
<p:row>
<p:column>
<f:facet name="header">Parent name</f:facet>
</p:column>
<p:column>
<f:facet name="header">Child name</f:facet>
</p:column>
<p:column headerText="Actions"/>
</p:row>
</p:columnGroup>
<p:subTable var="child" value="#{parent.children}">
<f:facet name="header">#{parent.name}</f:facet>
<p:column>#{child.name}</p:column>
<p:column>
<p:fileUpload fileUploadListener="#{bean.handleFileUpload}"/>
</p:column>
</p:subTable>
</p:dataTable>
I am using PF 5.3, on (weblogic 11g/jsf2.0/java 1.6).
I thought the issue of not shown emptyMessage in Datatable is fixed in 5.3, but inspite of using the latest version, i still dont see the message. Below is my sample code.
<p:dataTable id="attaDt" var="fileRow" value="#{pendpaybean.selectedPayDetailsFiles}"
rowIndexVar="rowIndex"
emptyMessage="No Files Uploaded"
>
<p:column headerText="Uploaded Date"
width="15px;" style="text-align:center"
>
<h:outputText value="#{fileRow.columns[0]}" />
</p:column>
<p:column headerText="Uploaded By"
width="30px;" style="text-align:center"
>
<h:outputText value="#{fileRow.columns[3]}" />
</p:column>
</p:datatable>
Any help ?
Your code works well. NOTE I put attribute value to null for showing emptyMessage.
Your adapted code:
<h:body>
<h:form>
<p:dataTable id="attaDt" value="#{null}" var="fileRow" rowIndexVar="rowIndex" emptyMessage="No Files Uploaded">
<p:column headerText="Uploaded Date" width="15px;" style="text-align:center">
<h:outputText value="#{fileRow.columns[0]}" />
</p:column>
<p:column headerText="Uploaded By" width="30px;" style="text-align:center">
<h:outputText value="#{fileRow.columns[3]}" />
</p:column>
</p:dataTable>
</h:form>
</h:body>
I have an editable table:
<p:dataTable id="myTable" ... editable="true"></p:dataTable>
There is only one line in the table and I want a cell of this line to be clickable in order to open a pop-up.
I tried the solution given there
<p:column id="myColumn" headerText="name" styleClass="align-center">
<p:cellEditor>
<f:facet name="output">
<h:panelGrid update="#widgetVar(infosNameFormDialog)" onClick="PF('infosNameFormDialog').show();">
<h:outputText value="#{element.name}" />
</h:panelGrid>
</f:facet>
<f:facet name="input">
<p:inputText value="#{element.name}" />
</f:facet>
</p:cellEditor>
</p:column>
This solution has a problem: because of the h:panelGrid I have a rectangle that frames the data of the cell, which is not acceptable.
So I tried with a p:link as other solution
<p:column id="myColumn" headerText="name" styleClass="align-center">
<p:cellEditor>
<f:facet name="output">
<p:link update="#widgetVar(infosNameFormDialog)" onClick="event.preventDefault(); PF('infosNameFormDialog').show(); event.stopImmediatePropagation();">
<h:outputText value="#{element.name}" />
</p:link>
</f:facet>
<f:facet name="input">
<p:inputText value="#{element.name}" />
</f:facet>
</p:cellEditor>
</p:column>
Now I can edit the cell with any value I want and I get a link which allows to open a pop-up.
But when there is no data in the cell, there can't be any link...
And I don't have any ideas to solve this problem
I use Primefaces 5.1
I have a treeTable where I have to set on the first column a Radionbutton.
the RadionButton is not linked to the treeTable.
I tried with the selectionMode but in vain.
If you have any idea, please share it with me.
Thanks in advance :)
My treeTable should look like this :
here is the code I used :
<p:treeTable value="#{treeBouchon.racine}" var="ligneBudgetaire"
selection="#{treeBouchon.ligneBudgetaireselectionnee}"
selectionMode="single" rowKey="#{ligneBudgetaire.id}">
<p:column selectionMode="single">
</p:column>
<p:column headerText="Ligne budgétaire">
<h:outputText value="#{ligneBudgetaire.filed1}" />
</p:column>
<p:column headerText="ETP reçus">
<h:outputText value="#{ligneBudgetaire.filed2}" />
</p:column>
<p:column headerText="ETP émis">
<h:outputText value="#{ligneBudgetaire.filed3}" />
</p:column
</p:treeTable>