Constructors
Name | Type | Description |
---|---|---|
title |
string |
The title of the list that will be displayed in the lists toolbar |
Example
//#import "ScriptList"
var random = function(array) {
return array[Math.floor(Math.random() * array.length)];
};
var startIndex = typeof start === "string" ? parseInt(start) : 0;
var itemCount = typeof limit === "string" ? parseInt(limit) : 50;
var list = new otris.scriptlist.List("My API List");
list.setStartIndex(startIndex);
list.setShowSearchBox({remoteSearch: false});
// Static reference data for the list
var month = ["January", "Febuary", "March", "April", "May", "June", "July", "September", "October", "November", "December"];
var stati = ["_image:custom/bullet_ball_glass_red.gif", "_image:custom/bullet_ball_glass_yellow.gif", "_image:custom/bullet_ball_glass_green.gif"];
var check = ["0", "1"];
var zeros = "000000";
// Creating the list columns
list.addColumn("Status", "Status", "CUSTOM");
list.addColumn("Nummer", "Nummer");
list.addColumn("Month", "Month");
list.addColumn("Erledigt", "Erledigt", "CHECKBOX");
list.setGroupHeaderTemplate('<div style="padding-left:calc({{index}}*15px)"><span class="otrIcon"></span><b>{{value}}</b></div>');
list.setGrouping(["Month"]);
list.setCollapsed(false);
// Fill the list with data
for (var i = startIndex; i < startIndex + itemCount; i++) {
var stringi = i + "";
var row = list.addRow([random(stati), "#" + zeros.substr(0, zeros.length - stringi.length) + i, random(month), random(check)]);
if(i%3==0) {
row.setTag('<div style="background: green;width: 3px;position: absolute;top: 1px;bottom: 1px;left: 2px;height: auto;"></div>');
}
else if(i%5==0) {
row.setTag(true);
}
else if(i%7==0) {
row.setTag('<div style="background: blue;width: 3px;position: absolute;top: 1px;bottom: 1px;left: 2px;height: auto;"></div>');
}
else if(i%11==0) {
row.setTag('<div style="background: red;width: 3px;position: absolute;top: 1px;bottom: 1px;left: 2px;height: auto;"></div>');
}
else if(i%2==0) {
row.setTag(true);
row.setTagColor("green");
}
}
// Return the data as JSON string
context.returnType = "scriptList";
return list.transfer();
Methods
-
addAction(action)
-
Adds a new action to the list.
Name Type Description action
ListAction List action to be addded to the list.
Name Type Description name
string Unique name of the action
label
string Label to display for this action
type
string Type of the action ("button" or "list") default: "button"
action
string Action to be executed, e.g., ("runScript:myScript&myParam=value")
imageFile
string optional The action is displayed with the referenced icon (
entypo:
orionicons:
syntax is supported). Only for typebutton
tooltip
string optional Optional tooltip
clientAction
string optional [ONLY USEABLE IN GADGET CONTEXT] Register a client function that is called with an array of ids if showCheckboxes is enabled
gadgetAction
string optional [ONLY USEABLE IN GADGET CONTEXT] Register a gadget action belonging to the same gadgetScript to be executed on click
-
addColumn(key, label, dataType){Object}
-
Add a column to the list
Name Type Description key
string | Object the technical name of the column
label
string the human readable label of the column
dataType
string the type of the column (STRING, NUMBER, CUSTOM or CHECKBOX)
Returns:
Type Description Object Object of otris.scriptlist.Column -
addListener(eventName)
-
Adds a listener to the ScriptList. If a registered event occurs the ScriptList script is called.
Withotris.scriptlist.getScriptListEvent
you can check if the script was triggered by an event.
Currently the following events are supported:reloadRow
Listen to file updates. Example for thescriptListEvent
:{name: "reloadRow", ids: ["dopaag_fi110", "dopaag_fi111", "dopaag_fi112"], loadedIds: ["dopaag_fi110", .., "dopaag_fi122"]}
In your script you have to check if the given ids are part of your list and/or if the referenced files matches your search criterias.
Theids
array contains the updated files and theloadedIds
array contains the ids of the currently loaded ScriptList rows.
For the return value you can use the helper classotris.scriptlist.RowUpdate
.moveRow
Listen to drop row event after one row or a selection of rows has been dropped at its new position. Example for thescriptListEvent
:{ name: "moveRow", ids: ["id_row_1", "id_row_2"], newIndex: 9 }
In your script you can either return a new list for complete rerendering or the ScriptList or return the strings MOVE_ROW_SUCCESS and MOVE_ROW_DENIED to allow/reject dropping rows at the new position. If the user should get a message when dropping the row, anotris.scriptlist.MoveRowResult
can be returned.
Example forotris.scriptlist.MoveRowResult
:{ success: false, message: "The row can't be moved to this position." }
Name Type Description eventName
string event name (currently supported:
reloadRow
andmoveRow
(since Documents 5.0e))- Since:
- Documents 5.0c
Examples
// NOTICE: The ScriptList object must be filled with the column information to work correctly // Check if the ScriptList script was triggered by an event var event = otris.scriptlist.getScriptListEvent(); if (event && "reloadRow" === event.name) { // Check the given ids in the array event.ids // Add the updated rows. If an id references a row that should be deleted just do not add any row data var rowUpdate = new otris.scriptlist.RowUpdate(); rowUpdate.addEntry("id5", {columnOne: "New value for column one"}); return rowUpdate.transfer(); } // ...
Move row was denied with message being displayed:
var event = otris.scriplist.getScriptListEvent(); if (event.name === "moveRow" && moveDenied) { return new otris.scriptlist.MoveRowResult({ success: false, message: "The row can't be moved to this position." }); } // ...
Simple success and deny move row:
if (event.name === "moveRow") { if(moveDenied) { return "MOVE_ROW_DENIED"; } else { return "MOVE_ROW_SUCCESS"; } } // ...
-
addParameter(key, value)
-
Add a parameter that will be send to the script when the next page is beeing
retrieved (infinite scrolling)Name Type Description key
string Name of the parameter
value
* Value of the parameter
-
addRow(key, values){otris.scriptlist.Row}
-
Add a row to the list
Name Type Description key
string The UNIQUE key of the row. (Can be a fileId or any other unique id)
values
Array.<*> | Object An array containing the values of this row in the order of which the columns has been added to the list OR an object mapping the column keys to the columns values.
Returns:
Type Description otris.scriptlist.Row -
addSettings(option)
-
Adds a setting (an option that can be defined by the user) to the gadget.
Name Type Description option
GadgetSetting | Array.<GadgetSetting> Setting(s) to add to the gadget.
-
endList()
-
Mark this list object to contain the last entries of the total list. Using this function means
"the entries contained in this list are the last ones in the overall list" -
getScriptListEvent()
-
setAutoColumnWidth(autoWidth)
-
Sets whether or not the columns should take up the entire available space of the table automatically
Name Type Description autoWidth
boolean true for the columns to take up the full width of the table
-
setAutoHeight(autoHeight)
-
Sets whether all rows should be displayed without scrollbar.
Name Type Description -
setAutoShowDetails(autoShow)
-
Set whether or not the details row of the entries should be expanded automatically
when an entry is clicked.Name Type Description autoShow
boolean Show detail rows automatically
-
setCollapsed(collapsed)
-
Set list to display groupings collapsed.
Name Type Description collapsed
boolean true, if the list is collapsed
-
setColumns(columnArray)
-
Set the columns. Removes any columns that have been added before.
Name Type Description columnArray
Array.<otris.scriptlist.Column> Array of column configurations
-
setCompactView(compactView, lineHeight)
-
Set the compact view setting for the list
Name Type Description compactView
boolean | string true for default compact view or a String as a template for the compact view
lineHeight
number line height of the compact view line
-
setCompactViewWidth(width)
-
Set the maximum with that the compact view will be used for (the point where the view is switched from full view to compact view)
Name Type Description width
number the with where to switch at
-
setDetailsParams(detailsParams)
-
Set the parameters that should be send to the details script when expanding a details row
Name Type Description detailsParams
Object object of the parameters to pass to the script
-
setDetailsScriptName(detailsScriptName)
-
Set the name of the script that will be called when a details row is expanded.
Allowed returnTypes for the script are: "HTML" and "ScriptList"Name Type Description detailsScriptName
string The scriptName
-
setEnableTextSelection(enableTextSelection)
-
This can be used to explicitly allow text selection if moveRows is also activated or
just to disable text selection if unwanted.Name Type Description - Since:
- Documents 5.0e
-
setFitGroups(fitGroups)
-
Will set the grid height so all groups can be expanded. Can only be used with fitHeight = true.
Name Type Description fitGroups
boolean Set grid height so all groups will fit expanded
- Since:
- Documents 5.0e
-
setFitHeight(fitHeight)
-
Try to resize the grid until all rows fit (only applicable for subgrids)
Name Type Description fitHeight
boolean Resize grid until content fits
- Since:
- Documents 5.0d
-
setFitHeightOnGroupCollapse(fitHeightOnGroupCollapse)
-
Sets whether the height of the grid should be increased if expanding the group
would cause a scrollbar to be shown. Can only be used with fitHeight = true.Name Type Description fitHeightOnGroupCollapse
boolean Fit height of grid so only the collapsed group will be visible
- Since:
- Documents 5.0e
-
setFitHeightOnGroupExpand(fitHeightOnGroupExpand)
-
Sets whether the height of the grid should be increased if expanding the group
would cause a scrollbar to be shown. Can only be used with fitHeight = true.Name Type Description fitHeightOnGroupExpand
boolean Fit height of grid so all rows of the expanded group will be visible
- Since:
- Documents 5.0e
-
setForceCompactView(forceCompactView)
-
Sets whether or not the compactView should always be displayed, even is the table is wide enough to display the normal table view
Name Type Description forceCompactView
boolean Always show list in compact view
-
setGroupHeaderTemplate(groupHeaderTemplate)
-
Set template for rendering group header HTML
Name Type Description groupHeaderTemplate
string Template string to use (e.g.
<div style="padding-left:calc({{index}}*15px)"><span class="otrIcon"></span><b>{{value}}</b></div>
) -
setGrouping(groupings)
-
Set the groupings for the list.
Name Type Description groupings
Array.<(string|Object)> Array of names and/or objects of columns to group by. Object notation: { column_id: string, collapsed: boolean }
-
setHeight(height)
-
Set the height for the current grid (only applicable for subgrids)
Name Type Description height
number Height of the details row
-
setHTMLHeader(htmlheader)
-
Adds a html header to the table which is displayed above the table.
Name Type Description htmlheader
string the html to display
-
setMaxHeight(maxHeight)
-
Set the maximum height for the current grid (only applicable for subgrids)
Name Type Description maxHeight
number Maximum height of the detail rows content
- Since:
- Documents 5.0d
-
setMinHeight(minHeight)
-
Set the minimum height for the current grid (only applicable for subgrids)
Name Type Description minHeight
number Minimum height of the detail rows content
- Since:
- Documents 5.0d
-
setMoveRows(moveRows)
-
Sets whether rows can be moved to other positions by drag and drop. The row will be moved on client side only.
Name Type Description moveRows
boolean allow moving rows to a new position
- Since:
- Documents 5.0e
-
setNavibarEntry(options)
-
Add a navibar entry. Define a script with parameters that reloads the scriptlist.
Only works if scriptlist is displayed in main list view area.
If scriptlist is used as gadget use thesetNavibarEntry()
from the gadget api.Name Type Description options
object | boolean navibar entry options or
true
for using default valuesName Type Description label
string optional label for the navibar entry (defaults to the scriptlist title)
scriptName
string optional label for the navibar entry (defaults to the value of
context.scriptName
)scriptParams
object optional key/value object for optional script parameter
- Since:
- Documents 5.0e
-
setResizableRows(resizableRows)
-
Allows resizing of rows.
Name Type Description resizableRows
boolean Allow resizing rows.
-
setResizeColumnsToContent(resizeColumnsToContent)
-
Sets whether columns should be resized to its content.
Attention: This only work with showHeader = true !!!Name Type Description resizeColumnsToContent
boolean -
setSearchContext(searchContext)
-
Sets the name of the search context (displayed in the searchbar).
If no name was set for the searchContext, the list's name will be used.Name Type Description searchContext
string | Object The search context name or a config object
Name Type Default Description name
string optional The search context name
remoteSearch
boolean true optional Enable/disable remote search
liveSearch
boolean false optional Automatic search after keyboard input (since Documents 5.0e)
Example
scriptList.setSearchContext({ name: "ScriptList Client Search", remoteSearch: false });
-
setShowCheckboxes(showCheckboxes)
-
Set whether or not to display a checkboxes for each column for multi selection
Name Type Description showCheckboxes
boolean Show checkboxes
-
setShowDetailsColumn(showDetailsColumn)
-
Set whether or not to display a column containing a + sign for each entry that can be
used to expand the entry and show some details inside the table.Name Type Description showDetailsColumn
boolean Show the plus sign
-
setShowGroupCheckbox(showGroupCheckbox)
-
Enable a checkbox inside the group header
Name Type Description showGroupCheckbox
boolean Enables the group checkbox if true.
- Since:
- Documents 5.0d
-
setShowHeader(showToolbar)
-
Show or hide the list header (column labels)
Name Type Description showToolbar
boolean show the list header (column labels)
-
setShowIndexNumbers(showIndexNumbers)
-
Show or hide the index numbers for each row on the left side of the grid.
Name Type Description showIndexNumbers
boolean Show index numbers
- Since:
- Documents 5.0e
-
setShowMoveColumn(showMoveColumn)
-
Set whether or not display an extra column for dragging rows if moveRows or moveRowsRemote is enabled.
Name Type Description showMoveColumn
boolean Show the drag column
- Since:
- Documents 5.0e
-
setShowQuickFilter(showQuickFilter)
-
Displays a filter field above each column for filtering its content.
This can only be used if showHeader is true.Name Type Description showQuickFilter
boolean Show filter
- Since:
- Documents 5.0e
-
setShowSearchBox(showSearchBox)
-
Set whether or not to display a search box in the toolbar
Name Type Description showSearchBox
boolean | Object True for searchbox with default remote search. Object: { remoteSearch: boolean }
-
setShowTitle(showTitle)
-
Sets whether the title should be displayed. This can be used to for example only show the button or just a search box without the scriptlists title.
Name Type Description showTitle
boolean show or hide title
- Since:
- Documents 5.0f
-
setShowToolbar(showToolbar)
-
Show or hide the lists toolbar
Name Type Description showToolbar
boolean show the toolbar
-
setSort(sort)
-
Set sorting for the list
Name Type Description sort
boolean | Object True for sortable with default remote sort, Object: { sortable: boolean, remoteSort: boolean}
-
setStartIndex(startIndex)
-
Set the start index of the list. The index of the first entry in this list object
in relation to the total number of entries in the list.Name Type Description startIndex
number Index of the first entry
-
setStickyGroupRows(stickyGroupRows)
-
Will stick group rows to the top of the grid while scrolling through the group.
Name Type Description stickyGroupRows
boolean Stick group rows to top
- Since:
- Documents 5.0e
-
setSublistBlobThumbnails(sublistBlobThumbnails)
-
Shows the rows' sublists as a single row of blob thumbnails.
For this to work correctly, all information needed to render the thumbnail must be available on the subrow.Name Type Description sublistBlobThumbnails
boolean Shows the sublist as a row ob blob thumbnails.
- Since:
- Documents 5.0e
-
setTitle(title)
-
Set the title of the list.
Name Type Description title
string list title
-
transfer(){string}
-
Return a proper JSON representation of this list.
Returns:
Type Description string JSON representation that can be used as a return value of a PortalScript