[ovirt-devel] Sortable columns in UI
Vojtech Szocs
vszocs at redhat.com
Tue May 13 14:37:51 UTC 2014
Hey guys,
oVirt UI has been missing column sort functionality for quite a while
now, but here's some good news.
I've just merged patch [1] that adds support for both server-side and
client-side sorting of table columns. This patch adds the necessary
infra/API; column sorting must be enabled per-column for given table,
just like with column resizing.
[1] http://gerrit.ovirt.org/#/c/25910/
Currently, only TextColumnWithTooltip (and its subclasses) support
sorting, however this can easily be changed in future by having the
column class extend SortableColumn.
To enable sorting:
// Enables server-side sorting via search query
// ... SORTBY name ASC|DESC
column.makeSortable("name"); // consider using shared constant
-or-
// Enables client-side sorting using comparator
column.makeSortable(comparator);
In order for server-side sorting to work properly, corresponding
SearchableListModel must apply the search options while executing
"Search" query.
For example, in DataCenterListModel:
@Override
public boolean supportsServerSideSorting() {
// Default is false
return true;
}
@Override
protected void syncSearch() {
// Append "SORTBY" clause to search query
String search = applySortOptions(getSearchString());
...
}
If a model doesn't support server-side sorting, client-side sorting
will be used as fall back (assuming a comparator was provided).
In general, all main tab list models in WebAdmin utilize "Search"
query, so we can enable server-side sorting for columns that exist
within main tab tables.
As for sub tabs (whose list models generally don't use "Search"
query, but also don't support paging at the moment), these can
simply use client-side sorting, i.e. reuse existing comparators
defined in Linq class.
PS: I've attached a screenshot depicting sorted column in action.
Regards,
Vojtech
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sorted-column.png
Type: image/png
Size: 6648 bytes
Desc: not available
URL: <http://lists.ovirt.org/pipermail/devel/attachments/20140513/ab6d3c57/attachment-0001.png>
More information about the Devel
mailing list