So I have a small bug to fix, this part of code isn't written by me, so I don't really know why this happening.
So there is a <p:dataTable> in a <p:tab>
and first column is just a a checkBox to put a checkMark on particular row or to check all rows in a table.
So when I check first checkbox it checks every row, but it doesn't put a check mark on it's self..
Any ideas why is that?
This is the markup for this column:
<p:column style="width:16px;text-align:center" selectionMode="multiple" rendered="#{!serviceFolder.isAccess}"/>
using JSF , primefaces 5.1
Related
I have a p:dataTable. In this table, I have a checkbox in a column. This is the code:
<p:selectBooleanCheckbox
value="#{var.selected}"
itemLabel="#{var.description}"
/>
After I add a row and update the whole table, the selected checkboxes after the row inserted have the checks shifted up! But it's only a graphical problem! The checkboxes that now appears unchecked are yet checked, because I show other things in the row if the checkbox is selected. On the contrary, the checkbox that now appear checked do not show the additional components.
I checked the html, and the classes and attributes that make them checked disappears. But debugging the backend I see that the in the list connected to the table, after the add, all the items have the expected value.
This is a minimal reproducible example:
https://ufile.io/6a60kxpn
I don't know why, but I solved putting process="#this" to the actionButtons. If someone can explain me why, I'll accept the answer.
Using
<p:dataTable
id="myissues"
value="{myIssuesController.myIssuesListModel.issueList}"
var="issueElement"
selection="#{issue}"
selectionMode="single"
rowKey="#{issueElement.idIssue}"
>
along with:
<p:ajax
event="rowSelect"
listener="#{myIssuesController.onSelectOneRow}"
update=":issueDetail"
oncomplete="PF('issueDetail').show();"
/>
I can open a dialog when I select a row on my dataTable.
How can I add an editable column to my table that goes into edition mode instead of opening the detail dialog when I click on one of its cells?
My first idea is to simply make the column editable and execute an oncomplete function that checks if the column selected is editable:
If it is, it will let it go into edition mode; if not it will call PF('issueDetail').show(); and show the detail dialog.
Only I don't know how to check if a particular column has been selected. How can I do that?
Should I do it like this or is there a simpler solution?
I solved using primefaces selection.
Basically, I removed the <p:ajax> component and added an extra column with a magnifier icon and a row editor icon to open the detail dialog / edit the entry; which is a more intuitive and user friendly solution than using the row selection action. The extra column looks like this:
<p:column style="width:32px;text-align: center">
<p:commandButton update=":issueDetail"
action="#{myIssuesController.onSelectOneRow}"
oncomplete="PF('issueDetail').show()"
icon="ui-icon-search" title="View" />
<p:rowEditor />
</p:column>
I am currently having a minor problem with the rendered attribute of column in my dataTable using PrimeFaces 4.0. I have a column in my table which should not always be displayed, so I used its rendered attribute and fetching the value from my backing bean. This is the 6th and last column. The dataTable is inside a p:dialog which will be shown at the end of the method.
The rendered attribute seems to work correctly because when showColumn is false, the column will not be shown and vice versa, but there's an issue. As seen in the image, the "No records found." message can't seem to reach until the last column. When I try to remove the rendered attribute, or manually set it to true (not using the backing bean value), the "No records found." message will reach until the last column as expected.
The entire dialog/form containing these elements seem to be updated correctly after the ajax request.
Backing Bean method:
public void getStatus(final MyClass foo, boolean showColumn) {
updateForm(foo);
setShowColumn(showColumn);
RequestContext.getCurrentInstance().execute("dailyStatus.show();");
}
Column Portion in xhtml:
<p:column headerText="Problematic Column" styleClass="tablecenter" rendered="#{myMBean.showColumn}">
<p:commandLink id="view"
action="#{myMBean.doSomething}" update="#form"
rendered="#{obj.status.equals('FAILED')? 'true' : 'false'}"
onclick="spin_start()" oncomplete="spin_stop()">
<h:graphicImage name="images/restart.png" styleClass="icon" />
</p:commandLink>
</p:column>
As Displayed on the Table:
For PrimeFaces 4.0 there is a 'solution' where I resorted to a hack-ish fix to the problem using jQuery. For recent PrimeFaces versions this is already fixed
When the dynamic column needs to be displayed, I use flags in my backing bean then call this method. (and the list for the datatable should be null or empty, as mentioned in the issue)
RequestContext.getCurrentInstance().execute("$('[id=\"myForm:myDataTable\"] tr.ui-widget-content td').attr('colspan', 6);");
This forces the single td's colspan on the row after the header row to reach up to the last header column. Hope this helps others that encounter this issue in the future!
I am using primefaces 3.5
I have a p:selectonemenu in one of the column in datatable. and also I have a submit button on another column of same datatable. When I do a submit the row will get removed.
Here when I am selecting 'Other' then do a submit action and updating the form, the p:selectonemenu items in other rows is getting 'other' as first value. What is way to set 'other' to last value everytime
<p:column headerText="Buyer Response" style="white-space:pre-line;">
<p:selectOneMenu value="#{buyerInProcessBean.subject}"
id="buyerResponseId" >
<f:selectItems
value="#{buyerInProcessBean.subjectMap[trans.decisionrule.ruleId]}"
var="subject" itemLabel="#{subject}" itemValue="#{subject}"></f:selectItems>
<f:selectItem itemLabel="Other" itemValue="Other" ></f:selectItem>
</p:selectOneMenu>
</p:column>
Since you have
<p:selectOneMenu value="#{buyerInProcessBean.subject}">
The subject is shared between all rows, of course, other select menus will have the same value as the one selected (other in your case). For that, I suggest a simple fix, you have to move the subject attribute to the objects you are iterating on.
Another fix, is to set the subject attribute to "Other" once your method executed on submit is finished. But with this, even the changed selectmenu will lose "Other" as value.
So in conclusion, you have to change your logic, so that subject won't be shared between rows
I have datatable with multiple checkbox selection (PF 3.3.1). I've defined column:
<p:column selectionMode="multiple"/>
I would like add some text or icon to header and I tried with headerText column attribute and with facet:
<f:facet name="header">
<h:outputText value="Header text" />
</f:facet>
But it doesn't work.
It is possible to modify header of checkbox selection column?
In case you want that feature badly and don't mind to use jquery, You could do something like
I tested it on primefaces shocase and it works (run these command at the console)
$("<span class='someClass'>Hellow</span>").insertAfter($('#form\\:multiCars thead tr:eq(2) th').find('.ui-chkbox-box'))
note that #form\\:multiCars should be changed with your table id
and tr:eq(2) refers to the third row in the table , cause in showcase the row with the headers is third
to change the width of that selection column you can use
$($('#form\\:multiCars thead tr:eq(2) th')[0]).css('width',100)
I'm aware of the fact that its waaaay ugly , but it works :)
Also you will have to run this script after each ajax rendering of the table