answered
2015-05-08 00:19:54 +0800
orthello 18 ● 2 Code is below. My Comparators are being changed dynamically. That means that I needed serveral NotifyChanges to take place (and have their effect on the screen) before I called sort. binder.postCommand() was how I allowed those NotifyChanges to take place (and be processed) before sorting. ZK staff helped me with this. Thanks!
Do you believe it? All of that just to get the up and down arrows on the column headers to show up. #DontLikeDisappearingColumnHeaderArrows
@Command ( "updateNameDisplayFormat" )
public void doUpdateNameDisplayFormat (
@BindingParam ( "format" ) String format,
@ContextParam ( ContextType.BINDER ) Binder binder )
{
cNameDisplayFormat = format;
// Set to ascending order every time format is changed
cCurrentSortDirection = true;
logToAppLog ( Level.DEBUG, "Name Display Format: " + format );
if ( getIsLastFirstDisplayFormat () )
{
cCurrentFullNameComparator =
new PanelJurorLastNameFirstNameComparator ();
}
else
{
cCurrentFullNameComparator =
new PanelJurorFirstNameLastNameComparator ();
}
BindUtils.postNotifyChange ( null, null, this, "nameDisplayFormat" );
BindUtils.postNotifyChange ( null, null, this, "lastName" );
BindUtils.postNotifyChange ( null, null, this, "firstName" );
BindUtils.postNotifyChange ( null, null, this,
"fullNameAscendingComparator" );
BindUtils.postNotifyChange ( null, null, this,
"fullNameDescendingComparator" );
// http://forum.zkoss.org/question/89540/wrong-scrollbar-position-when-clear-listbox-items/
// http://tracker.zkoss.org/browse/ZK-1834
// For the scrollbar on the listbox to behave perfectly
// we need to upgrade ZK to version 6.5.5 when it becomes
// available.
// If user changes name display then a re-sort is implied
// Always send true (ascending order)
// Every time the display format is changed we want sort to start off
// as ascending
// This means that all decending sorts will be done through
// the listheader
binder.postCommand (
"sortPanelJurorListModel",
Collections.<String, Object>singletonMap (
"ascending", cCurrentSortDirection ) );
}
@Command ( "sortPanelJurorListModel" )
public void doSortPanelJurorListModel (
@BindingParam ( "ascending" ) boolean isAscending )
{
// It is surpremely important that getFullNameAscendingComparator and
// getFullNameDecendingComparator methods be called instead of
// referencing class variables due to the event timing of the
// NotifyChanges in doUpdateNameDisplayFormat
if ( isAscending )
{
cPanelJurorListModel.sort (
getFullNameAscendingComparator (),
isAscending );
}
else
{
// As code sits now will never get here
cPanelJurorListModel.sort (
getFullNameDescendingComparator (),
isAscending );
}
}
do you have defined sort in your columnsheaders?
chillworld ( 2014-04-18 05:23:40 +0800 )editYes, see below.
orthello ( 2015-05-08 00:25:45 +0800 )edit