Configuring Sort Order

Sort order relates to the order of all characters in the unicode character set (for example, numeric, alphabetic, symbol, and so on). You may wish to customize the sort order that Openspace uses, for example, because of locale-specific conventions.

If you want to change the sort order, you can write your own customized sort definition in the callout.js script provided by Openspace. See Configuring Custom Functionality for more information about the callout.js script file. Then, by setting the hook.onCollateStrings property in the config.properties file to true, every string comparison goes through the hook.onCollateStrings property and calls callout.js until the column is sorted. See Openspace Configuration Overview for the location of the config.properties file.

By default, the hook.onCollateStrings property is set to false. If you set the hook.onCollateStrings property to true, but do not amend the callout.js script, then the comparison function used is a.localeCompare(b). This compares two strings together using the locale that your browser is using.

The following example illustrates changing the default sort order of the State column in the Process Views gadget. It swaps pi_halted and pi_started so they start at opposite ends in the sequence. Shown below is the default ascending sort order for the State column in the Process Views gadget.

Shown below is the default descending order of the State column in the Process Views gadget.

The following Javascript swaps pi_halted and pi_started so they start at opposite ends in the sequence
var result = "0";
if ( (context == "ProcessTemplageGadgetView-instances") && ("pi_" == a.substr(0,3)) )
{			
if( a ! = b)
 {	if( a == "pi_halted" || b == "pi_started" )
  {		
   result = "-1"; //always collate lower
  }
  else
  {
   result= "1"; //always collate higher
  }
 }
}
else
}
 var ret = a.localeCompare(b);
 if (ret < 0)
 {
  result= "-1";
 }
 else
 }
  if( ret > 0)
  {
   result= "1";
  }
 }
}
window.alert("e) javascript onCollateStrings(" + context + ") locale=" + locale + " a=" + a + " b=" + b+" result="+result return result;         
Note: You can capture diagnostics about the sort comparisons made by the callout.js script in the Logger gadget. By setting hook.onLoadOpenspace=true in the config.properties file, any window.alert messages in the callouts.js script are redirected to the Logger gadget.
Note that:
  • Passing the parameter locale allows you to change different sort orders for different locales.

  • Passing a parameter context indicates which component is calling the hook.onCollateStrings property.
  • Parameters a and b are the two strings that are compared.
  • The function must return

      -1 to indicate lower.

      0 to indicate identical.

      1 to indicate higher.

Shown below is the customized sort of the State column in the Process Views gadget in ascending order.

Shown below is the customized sort of the State column in the Process Views gadget in descending order.

Procedure

  1. Open the config.properties file in a text editor.
    Note: TIBCO recommend that you take a backup of the config.properties file before amending it.
  2. Uncomment the hook.onCollateStrings property and set it to true. Initially, the property is commented out and set to false. For example, hook.onCollateStrings=true.
  3. Save and close the config.properties file.
  4. Log out and log back into TIBCO Openspace for the changes to take effect.