QScript ComboboxControl

From Q
Jump to navigation Jump to search

ComboboxControl

The Combobox control (also known as a drop-down control) allows you to select from a list of values. The values that appear in the Combobox can be set in the itemList property. This is a string seperated by semicolons, e.g.: Choice One; Choice Two; Choice Three. Alternatively, the values can be set from a Calculation. This is done by setting the itemsFromROutput property to a Calculation that you want to use as the source.

deleteItem()

Deletes a table, plot or sub-group.

dependants(recursive)

Returns an array containing the variables, questions, tables, R items, or other items that are used when calculating this object. A Table object will return an array containing the questions it is a crosstab for, and any variables used as filters or weights. An ROutput object will return other ROutput objects used in its calculations. A JavaScript Variable object will return the variables referenced in its formula, etc.
recursiveOptional. If true then it will return all the objects that are normally returned, as well as all objects that those objects depend on, and so on.
Returns:Returns an array containing Question objects, Variable objects and AnalysisItem objects.

equals(obj)

Whether two objects are the same.
objThe object to compare against.
Returns:true or false
Example:
data_file.getQuestionByName('Q2').equals(data_file.questions()[0])

exportToExcel(filename, options)

Exports an item or group to Excel. This method is currently only available in desktop Q.
filenameThe name of the exported file.
optionsAn optional dictionary of options to pass to the function. These map to the settings in the Table Options dialog when exporting in Q using the fast Excel export option:
table_style: The name of an Excel-based table style to use for the export. See the dropdown in the Q Excel export dialog for names - remove the spaces when used here.
notes: Text that appears as a comment in the first cell of every sheet.
hyperlink: A link applied if the project is uploaded as a Dashboard.
ignore_net_and_sum: Excludes the NET and SUM columns or rows from the exported table.
export_tables_as: When exporting multiple tables, how they should be laid out:
- OneWorksheetPerTable: each table is placed on a new worksheet.
- OneWorksheetPerPage: tables in the same group are placed on the same worksheet.
- OneWorksheet: all tables are placed on a single worksheet.
how_count: For multiple tables on the same worksheet, how they should be spaced:
- BetweenTops: use a fixed number of rows between the tops of tables.
- FromBottomOfOneToTopOfNext: leave a number of rows between the bottom of one table and the top of the next.
num_rows_between_tables: The number of rows used by how_count
include_table_of_contents: Whether to include a table of contents
perform_statistical_test_of_independence: Whether to perform a statistical test of independence for the entire table (NB: this is in addition to the tests automatically shown on tables).
repeat_headings: Whether to repeat headings for each table.
show_significance_arrows: Whether to include significance arrows (when shown in table).
table_names_sequential: Whether to name tables sequentially (e.g. Table 1, Table 2, etc.).
show_column_comparisons_in_separate_row: Whether to show column comparisons in a separate row.
Example:
project.report.exportToExcel('output.xlsx');
Example:
project.report.exportToExcel('output.xlsx', {
  table_style: 'TableStyleLight1',
  notes: 'Notes',
  include_table_of_contents: true,
});

filters

Get/sets the list of Variable objects to apply as filters for this analysis item. This only includes filters added to the object in Q. To get filters added in Displayr, see 'groupedFilters'
Example:
t.filters = [data_file.getVariableByName('awarenessCoke')];
Example:
t.filters = [];

group

Get the ReportGroup object that contains this table/plot/group, or null if the sub item of an item.

groupedFilters

Get/sets the list of Variable objects to apply as filters for this analysis item. This only includes filters added to the object in Displayr. To get filters added in Q, see 'filters'
Example:
t.groupedFilters = [data_file.getVariableByName('awarenessCoke')];
Example:
t.groupedFilters = [];

guid

Get the internal identifier for this object, which is unique for all objects in the Report.

height

Gets/sets the height of the item in pixels

hiddenFromExportedViews

Gets/sets whether this item is hidden from exported views in Displayr. If an item is hidden from exported views, then when you share or export the project, the item will not appear in the shared page or exported document. This is typically used if you are using Calculations for intermediate steps in calculating values, and these steps would be irrelevant or confusing for the person viewing the page.
Example:
routput1.hiddenFromExportedViews = true;

itemList

Gets/sets the item list.
Example:
combo.itemList = ['1','2','3'];

itemsFromQuestion

Get/sets the source of the items to the labels of a multi-part question
Example:
var combo = project.report.appendControl("Combobox");
combo.itemsFromQuestion = project.dataFiles[0].questions[4];

itemsFromROutput

Get/sets the Calculation source
Example:
var textR = project.report.appendR('c("Hello","World")');
var combo = project.report.appendControl("Combobox");
combo.itemsFromROutput = textR;

itemsFromTable

Get/sets the source of the items to the labels from a table
Example:
var combo = project.report.appendControl("Combobox");
combo.itemsFromTable = table;

left

Gets/sets the left position (i.e. X position) of the item in pixels

mustHaveSelection

Gets/sets whether the control can be cleared of selections. Valid options are Yes, No.
Example:
combo.mustHaveSelection = 'Yes';

name

Get/set the name for this object, as it appears in the Report.

placeholderText

Get/sets the placeholder text
Example:
var combo = project.report.appendControl("Combobox");
combo.placeholderText = "(select)";

referenceName

Get/set the reference name for this object, that is used to reference this object in the source code of other objects.

selectedItems

Get/sets the selected items. This will honor selectionMode regardless of input length.
Example:
var combo = project.report.appendControl("Combobox");
combo.selectedItems = ["First option"];
combo.selectedItems = ["First option", "Second option"];

selectionMode

Gets/sets the selection mode. Valid options are SingleSelection, MultipleSelection
Example:
combo.selectionMode = 'SingleSelection';

showCaption

Gets/sets whether to show the caption for this item. This setting is only useful in Displayr and where a caption is available.
Example:
plot.showCaption = true

size

Gets/sets the size (in mm) for this item, presented as an array containing two elements: width and height.
Example:
item.size = [100, 100];

subItems

Returns an array of the items under this object. Check their type to find out if they are tables, plots or sub-groups.

switchTo(item_type)

Switch the current item to a new type e.g. chart to table. NB: only transitions from Tables, Charts and Visualizations are supported
item_typeThe name of the item to switch to. This should match 'Table' or the title of its wiki page

top

Gets/sets the top position (i.e. Y position) of the item in pixels

type

Returns the name we use to refer to this class in the documentation.

whenItemListChanges

Gets/sets the behaviour to apply when the item list changes. Valid options are RemoveAllSelections, KeepCurrentSelection, SelectAll, SelectFirst
Example:
combo.whenItemListChanges = 'KeepCurrentSelection';

width

Gets/sets the width of the item in pixels