Expand functionality for rows in Richfaces DataTable - jsf

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.

Related

ace datatable groupBy column breaks when using pagination

Hope someone can help me out with this.
The issue is as follows:
I have a datatable that displays user variables. One of the columns on the table is grouped to show the variable type in one cell for all the variables that share the same type, which can be many, and since there could be so many I enabled datatable pagination.
However, the issue comes when the variables of a said type exceed the rows per page number and are splitted among various pages. In that case, when I navigate to the next page, the information meant to be in the grouped column is lost and the data from the other columns is moved one column to the left, therefore showing an incorrect column-value relationship (the last column of the table therefore left blank).
Here is the code for my datatable and grouped column
<ace:dataTable value="#{bean.variables}" paginator="true" filterEvent="enter" selectionMode="single" id="variableTable" rowSelectListener="#{bean.showVariable}" var="variable" rows="10" paginatorPosition="bottom" >
<ace:column groupBy="#{variable.type}" headerText="#{basicBundleBase.type}">
<h:outputText value="#{variable.type}" />
</ace:column>
<ace:column groupOn="#{variable.name}" headerText="#{basicBundleBase.name}">
<h:outputText value="#{variable.name}" />
</ace:column>
<ace:column headerText="#{basicBundleBase.description}">
<h:outputText value="#{variable.description}" />
</ace:column>
I've searched a lot around but haven't got any clue on how to solve this; checked on ace:column and ace:dataTable tags but just can't seem to figure out how to make it work. That's why I came here to ask for some help.
Hope someone can give me a hand with this issue!
Thanks in advance for your help and time!
Cheers
Tsuru

inputText inside table header: how to render only dataTable content

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?

Primefaces datatable scrolling not working as hoped

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="..." >

Datatable multiple checkbox selection - modify selection header

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

Is it possible the preselect a cell in Primefaces DataTable component?

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

Resources