is it possible to preselect a cell in the Primefaces DataTable component? How do I do that? Tried it already with a Primefaces Cell object with a Getter, but this is not called by my data table :-(.
I need this because I have to restore the selection of the cell done a request before, if validation tells me, that a required field in the form was not filled.
This is my xhtml code snippet:
<p:dataTable id="select-start-pos" var="item"
selectionMode="singlecell"
value="#{frankingController.startposItems}"
selection="#{frankingController.selectedCell}"
styleClass="startPosGrid">
<p:column id="startposcol1">
<h:outputText value=""/>
</p:column>
<p:column id="startposcol2" rendered="#{frankingController.startposColumns > 1}">
<h:outputText value=""/>
</p:column>
</p:dataTable>
Thank you for your help!
Mike
No and 3.x doesn't have cell selection feature
You can use Sheet control instead of Datatable, it has row selection feature.
http://www.primefaces.org/showcase-labs/ui/sheet.jsf
Related
I have a dataTable with a list of employees.
One column of the dataTable is the names of the employees.
I want to have an inputText inside the header of the column which the user can use to filter the employees by their names, e.g. when the user writes "smi" in the inputText, the dataTable should only show the employees with the name starting with "smi" like Smith. The table data should update while the user is writing into the inputText, that is why I am using ajax here.
This is my column:
<h:column>
<f:facet name="header">Name
<h:form>
<h:inputText id="suchString" class="suchString"
value="#{mitarbeiteransicht.suchString}">
<f:ajax event="keyup" execute="suchString" render="ma-tabelle" />
</h:inputText>
</h:form>
</f:facet>
#{ma.bezeichnung}
</h:column>
ma-tabelle is my dataTable.
Everytime the table is rendered, the inputText inside the header is losing the focus and the user needs to click it again.
Is there a way around this? Is it possible to exclude the table headers when rerendering?
I have an issue when I use a datatable with a filter and cellEditor. When filter 'on', I mean there's some value in it, cell editing works fine only few first attempts, 'onCellEdit' being call when I exit from cell. But after two successful editing begins strange behavior. Method 'onCellEdit' called when I enter the edit mode in cell and cell 'closed' immediately after it. What's wrong with my code?
I use PF 5.1 and editing mode is cell editing:
"Another option for incell editing is cell editing, in this mode a
cell switches to edit mode when it is clicked, losing focus triggers
an ajax event to save the change value."
Thank you.
UPDATE: This behavior begins when I entered in edit mode in one cell and after making change I clicked on another change before submitting my changes by pressing enter, if prior to enter another cell I press enter, everything in fine.
Update2: possible it's connected to this bug.
...
<p:ajax event="cellEdit"
listener="#{importsBean.onCellEdit(contact)}"
oncomplete="PF('contacts').filter()"
update=":form:messages name number description" process="#this" />
<p:column id="name"
headerText="Name">
<p:cellEditor>
<f:facet name="output">
<h:outputText id="name" value="#{contact.name}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{contact.name}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
...
I have a p:selectOneMenu when its selection changes, some controls will be updated below. This works so far, but I added an empty selection placeholder. When this is chosen the validation fails and the content below is no more updated. So I want to do validation only when a button is clicked which submits the form but not when the p:selectOneMenu selection changes. How I can do this?
<p:selectOneMenu id="jobDetailClass" value="#{paramController.selectedJobClass}" styleClass="selectJobClass"
label="#{msgs['label.jobClass']}" converter="jobClassConverter" validator="#{paramController.validateJobClassSelection}">
<f:selectItems value="#{paramController.getAvailableJobClasses(paramEditMode)}" var="curJobClass"
itemLabel="#{curJobClass.name}" itemValue="#{curJobClass}"/>
<p:ajax event="change" process="#this" update="jobClassElemsGrid" />
</p:selectOneMenu>
i have followed the primefaces showcase example for the datatable to make is scrollable across and while it works across it makes all the columns very small and i am unable to really read the columns, the reason for the scrollable function is because of the large amount of columns i need to display, is there any way of keeping the size of the columns but also make the datatable scrollable ?
here is the datatable code :
<p:dataTable id="UserTable"
widgetVar="usersTable"
paginator="true" rows="10"
value="#{usertableController.items}"
var="item"
emptyMessage="No details was found with given criteria"
scrollable="true" scrollWidth="400">
there are 14 columns in total i need to display
thanks guys
You can always give width= "X" to your <p:column> or <p:columns>. It works when the datatable is scrollable. As follows,
<p:column selectionMode="multiple" width="15" />
<p:columns width="150" value="..." var="..." columnIndexVar="..." sortBy="..." filterBy="..." >
I am looking for a way to implement a expand functionality to the rows of a Richfaces DataTable. The user would click a "+" link located in the first column (of each row) of the Datatable and the row would "expand" (meaning new text would be shown between the current row and the next).
I have that working, the only problem is that all the information in the expanded view is displayed in the first column section of that row. What I am trying to do is to show the "expanded" text in the whole row (as if the "expanded" text row is not divided by the columns).
Any suggestions? I'm a bit new at jsf/richfaces, so any sample code would be appreciated.
You can do this with the breakBefore attribute on the rich:column component. There is an example of its use on the RF demo page.
It would work for you if you had the last column define the breakBefore attribute. An example:
<rich:dataTable id="mytbl" value="#{mybean.mydata}" var="row">
<rich:column>
<a4j:commandLink reRender="mytbl">
<h:graphicImage value="#{row.toggleImage}"></h:graphicImage>
<a4j:actionparam name="shown" value="#{not row.expand}" assignTo="#{row.expand}"/>
</a4j:commandLink>
</rich:column>
<rich:column>
<f:facet name="header">col 2</f:facet>
<h:outputText value="#{row.col2}"/>
</rich:column>
<rich:column breakBefore="true">
spans all the other columns
</rich:column>
</rich:dataTable>
One way for this is you can use the JQuery feature.
Demo link http://jsfiddle.net/BU28E/1/ .
One extra overhead here is you need to check how the rich:dataTable renders as Html and provide the DOM model for jQuery. It is bit tricky to have such feature in richfaces and it needs some complex workarounds.