Sort/Reorder Rows or Columns - Sort Categories of Selected Table from Highest to Lowest (Updates When Data Changes)
Jump to navigation
Jump to search
This page is currently under construction, or it refers to features which are under development and not yet available for use.
This page is under construction. Its contents are only visible to developers!
This tool applies a Rule to the selected table so that the table is always sorted even when the results in the table change (e.g. due to filtering or updating your data set with new data).
Usage
- Select the table you want to sort.
- Use Sort > Rows in Table (Automatically Updates When Data Changes).
- If you want to change the way the table is being sorted:
- Go to Properties > RULES on the right.
- Right click the name of the sorting rule, which is Sort rows from highest to lowest (automatically updates when data changes).
- Select Edit.
- Change the options for sorting as needed.
includeWeb("QScript Selection Functions");
applySortRuleToSelection();
function applySortRuleToSelection() {
const web_mode = inDisplayr();
const user_selections = getAllUserSelections();
let selected_tables = user_selections.selected_tables;
if (selected_tables.length == 0) {
log("Select one or more tables to sort and then run this option again.");
return false;
}
// Add new sort rule to project
let sort_rule = project.rules.newFromLibrary("Sort/Reorder Rows or Columns - Sort Rows (Automatically Updates When Data Changes)", {});
// Add rule to selected tables
selected_tables.forEach(function (table) {
table.rules.add(sort_rule);
})
}
See also
- QScript for more general information about QScripts.
- QScript Examples Library for other examples.
- Online JavaScript Libraries for the libraries of functions that can be used when writing QScripts.
- QScript Reference for information about how QScript can manipulate the different elements of a project.
- JavaScript for information about the JavaScript programming language.
- Table JavaScript and Plot JavaScript for tools for using JavaScript to modify the appearance of tables and charts.