sortBy an EL Expression in primefaces - sorting

Is it possible to use sortBy with an EL expression containing multiple values in Primefaces , if it is how or how can i approach this.
Problem:
I Need to sory the table by latest date. There are two columns one with created date and another with updated date. if updated exist i need to use it to sort.
I looked at JSF 2 , Primefaces 4.0. p:dataTable sorting using complex sortBy expression
and PrimeFaces dataTable sorting not working but neither does what i need. second one was just in google search
Example
<p:column headerText="Last Logged in Date" sortBy="#{login.lastUpdated ne null ? login.lastUpdated : login.createdDate }">
<h:outputText value="#{login.lastUpdated ne null ? login.lastUpdated : login.createdDate }" >
<f:convertDateTime pattern="yyyy/MM/dd HH:mm" />
</h:outputText>
</p:column>
Any Advice would be appreciated.
Thanks in advance.

Related

Primefaces lazytable sorting change first sorting order

is there any way to allow, after the first request to sort a particular column, not to be listed first in ascending order, but first in descending order?
description:
If I need to sort the column in descending order, it is necessary to first click on the column in ascending order and only then reload the table with the sorted data as I require.
One not entirely nice solution that I use now is in the case of columns, where I require the reverse order, I simply swap the meaning ascending/descending when querying the DB. But the table does not show graphically correctly the arrow above the table in which direction I am sorting the data and it is necessary to intervene for the columns in CSS.
Is there a more elegant option?
Sorry for my easy English and thanks for any advice,
Venca.
As #Melloware pointed in comment datatable has fields sortBy and sortOrder which can be used for sorting.
See example:
<p:dataTable id="txnTable"
value="#{chTransactionsForm.transactions}" var="res"
sortMode="single" sortBy="#{res.activityDate}" sortOrder="DESCENDING"
rows="#{referenceData.recordsPerPage}" rowKey="#{res._lineNumber}"
lazy="true" resizableColumns="true"
paginator="true" paginatorPosition="bottom" paginatorAlwaysVisible="false"
paginatorTemplate="#{referenceData.paginatorTemplate}">
<p:column id="activityDate" headerText="#{msg.transDate}"
sortBy="#{res.activityDate}" width="120">
<h:outputText value="#{res.activityDate}">
<f:convertDateTime timeZone="#{referenceData.timezone}"
pattern="MMM dd, yyyy HH:mm" />
</h:outputText>
</p:column>
...

Apex Item in interactive report not being displayed correctly

I'm creating a interactive report and I want to dynamically create apex items (text fields) in it, but they are not being displayed correctly.
This is my code:
select
APEX_ITEM.text( p_idx=> 1 , p_value=> null, p_item_id => 'dynamic_item') as "Textfield"
from dual
connect by level = 3;
This shows up in the report:
<input type="text" name="f01" size="20" maxlength="2000" value="" id="dynamic_item" />
But I would like to get the actual item and not the code?
What am I doing wrong?
It looks like you didn't set the escape special characters property to "No".
Go on your report and select the column you created (Textfield).
Then on the right at "Security - Escape special characters" select "No".
Now it should be displayed correctly!

PrimeNG datatable performance very slow in case there is a lot of data

I use PrimeNG datatable. In case the table contains many rows, the datatable's performance works very slow.
This is my html:
<p-dataTable #dt [rowTrackBy]="rowTrackBy" [emptyMessage]="'TABLE.EMPTY_MESSAGE'|translate" #dt [rows]="rows" [paginator]="paginator"
lazy="false" [pageLinks]="3" scrollable="true"[editable]="editable" [styleClass]="paginator?'paginator': enableFilter?'scroll filter-table':'scroll'"
[globalFilter]="gb"[value]="displayList" resizableColumns="true" [(selection)]="selectedItem"
(onRowDblclick)="importButton?'':onRowDblclick($event.data)"[expandableRows]="showExpander" [expandedRows]="expandedRows"
(onRowSelect)="onrowSelect($event)" (onRowClick)="selectRow($event);onrowSelect($event)" (onRowUnselect)="onRowUnSelect($event)"[rowStyleClass]="rowStyleClass"
[selectionMode]="(enableSelect&&!showSelectColumn)?(multiSelect?'multiple':'single'):''" [metaKeySelection]="false"
(onHeaderCheckboxToggle)="onHeaderCheckboxToggle($event)">

Sorting rich:dataTable with second value in a column

I have a rich dataTable that has a column which contains the full name of a person (Last name, first Name). I currently have the table so that the columns can be sorted based on the last name of the person. However I want it so that if the last names are equal it will then sort by the first names next. Is this possible? How can I do it?
<rich:column sortBy="#{list.lastName}">
<h:outputLabel value="#{list.lastName} #{list.firstName}"/>
</rich:column>
Example:
If the names were (B Smith and A Smith)
Should be sorted:
Smith A
Smith B
That isn't possible with <rich:dataTable>.
You'd better add a (transient) getter which returns the "full name":
#Transient // Only if it's a JPA entity.
public String getFullName() {
return lastName + " " + firstName;
}
And then use it in sorting:
<rich:column sortBy="#{list.fullName}">

Grouping and Sorting in RadGid

I have a issue need to resolve.
How to group Data on Radgrid but no sort. Radgri only group, no sort. Because if Radgrid sort , data will incorrect
Please help me to resolve it
Thank all so much
Set the allowsorting property to false.
<telerik:radgrid id="RadGrid1" runat="server" allowsorting="False">
Also, if you need to know how to group data, use a GridCalculatedColumn:
<telerik:GridCalculatedColumn UniqueName="Name" HeaderText="Name"
DataFields="FirstName, LastName"
Expression="{0} + ' ' + {1}">
</telerik:GridCalculatedColumn>

Resources