Indenting Rows in a Table
Jump to navigation
Jump to search
Pages with syntax highlighting errors
Q Technical Reference
Q Technical Reference
Q Technical Reference > Setting Up Data > Creating New Variables
Q Technical Reference > Updating and Automation > JavaScript > Table JavaScript and Plot JavaScript > Table JavaScript and Plot JavaScript Examples Library
This example uses JavaScript to indent any rows in a table which do not contain the word "NET".
form.setSummary("Indent row labels");
var indent_string = " - ";
var row_labels = table.rowLabels;
var new_row_labels = row_labels
.map(function (str) {
if (str.indexOf("NET") > -1)
return str;
else
return indent_string + str;
});
table.rowLabels = new_row_labels;
This produces a result which looks like this:
Note that:
- The indentation is specified by indent_string in the second line. In this case it uses two spaces, followed by a dash and another space. If you want to use a different indentation then you can change this line.
- The code checks for "NET", and so is specific to the layout of your table and your choice for how to label things which should not be indented.
See also
- Table JavaScript and Plot JavaScript for an explanation of how to run this code.
- Table JavaScript and Plot JavaScript Reference for technical information.
- Table JavaScript and Plot JavaScript Examples Library for other examples.
- JavaScript for information about the JavaScript programming language.
- QScript for tools for automating projects using JavaScript.
- JavaScript Variables for detail on how to create new variables in the Variables and Questions tab using JavaScript.
Pages with syntax highlighting errors
Q Technical Reference
Q Technical Reference
Q Technical Reference > Setting Up Data > Creating New Variables
Q Technical Reference > Updating and Automation > JavaScript > Table JavaScript and Plot JavaScript > Table JavaScript and Plot JavaScript Examples Library