Constructors
Name | Type | Description |
---|---|---|
title |
string |
Set the title of the dialog if the module is displayed in a modal dialog |
viewId |
string |
optional
The viewId of the gadget object (The viewId specifies the destination in the DOM. This destination must exist otherwise the gadget is not rendered.) |
- Since:
- Documents 5.0b
Example
//#import "Gadget_API_Controller"
function gadgetUserExit() {
this.execute = function() {
// Create the gadget and set the title for the dialog
var tableData = new otris.gadget.gui.TableData("Datenübernahme (Nordwind-DB)");
// Add db connection
var myDB = new DBConnection("odbc", "Nordwind");
tableData.setDBConnection(myDB);
tableData.setSqlSelect("SELECT * FROM Kunden");
// Show the search box
tableData.setShowSearchBox(true);
// Add column config
tableData.setColumns([
{key: "Firma", label: "Firma", searchMode: "end", searchCaseSensitive: true},
{key: "Kontaktperson", label: "Kontakt", dataType: "string", searchable: false},
{key: "Position", label: "Funktion", dataType: "string", searchable: false},
{key: "Ort", label: "Ort", dataType: "string", searchMode: "start", searchable: false},
{key: "Land", label: "Land", dataType: "string", searchable: false}
]);
// Set key column name
tableData.setKeyColumn("Kunden-Code");
// Set the sql query for the details data
tableData.setDetailsSql('SELECT * FROM Kunden WHERE "Kunden-Code" IN (?)');
// Add the mapping between database fields and file fields
tableData.setMapping([
{fieldName: "crmName", columnName: "Kontaktperson", valueCallback: function(value) { return value.split(/\s+/)[1]; }},
{fieldName: "crmFirstName", columnName: "Kontaktperson", valueCallback: function(value) { return value.split(/\s+/)[0]; }},
{fieldName: "crmAccountnumber", columnName: "Kunden-Code"},
{fieldName: "crmCompany", columnName: "Firma"},
{fieldName: "crmPhone", columnName: "Telefon"},
{fieldName: "crmFax", columnName: "Telefax"}
]);
return tableData.transfer();
}
}
Extends
Methods
-
addAction(action)
-
Adds a new action to the list. For details see ScriptList API (ScriptExtensions).
Name Type Description action
ListAction List action to be addded to the list.
-
inherited addClientFunction(clientFunction)
-
Adds a JavaScript Function to this Transferable Object. When the Object is transfered to the client the functions added to this Object will be available on the client side.
Name Type Description clientFunction
function The function to be added to the clientFunctions of this Object. (Can be a JavaScript Function or an Object returned by otris.gadget.util.FunctionUtils.getFunctionObject)
-
inherited addContainerButton(buttonConfig){object}
-
Adds a container button.
If the gadget is displayed in a dialog the container buttons are rendered as dialog buttons (bottom right corner of the dialog).
Otherwise the container buttons are ignoredName Type Description buttonConfig
object button config object
Name Type Default Description id
string button id
label
string button label
clickFunction
string name of the client function to execute on click
disabled
boolean false optional - Since:
- Documents 5.0e
Returns:
Type Description object buttonConfig Example
// Alternative gadget action button gadgetForm.addContainerButton({ id: "myCustomSaveButton", label: "Speichern", clickFunction: "saveGadgetData" }); gadgetForm.addClientFunction(function saveGadgetData(event) { var gForm = documentsContext.getGadgetContext().getClientObject(); gForm.submitForm({ gadgetAction: "processForm" }, { showBusyPanel: true }); });
-
inherited addPdfButton(config)
-
Adds a button to download the displayed gadget as pdf. The button will show on hover in the left top corner of the gadget.
Name Type Description config
object optional config object
Name Type Default Description filename
string content.pdf optional filename of the pdf for download
buttonStyle
string left: 200px; optional style for the pdf button to be applied to
- Since:
- Documents 5.0d
Example
myGadget.addPdfButton({filename: "myCustomFilename.pdf", buttonStyle: "left: 200px; });
-
inherited addSettings(option)
-
Adds a setting (an option that can be defined by the user) to the gadget.
Name Type Description option
GadgetSetting | Array.<GadgetSetting> the setting(s) to add to the gadget.
- Since:
- Documents 5.0a
-
inherited onGadgetLoad(onloadHandler)
-
Sets an onLoad handler for the Gadget. The handler is executed when the gadget is displayed at the client.
Name Type Description onloadHandler
function | string the handler to be executed (must be either a javascript function or a string representing a function)
-
setColumns(columns)
-
Add the column configuration for the list.
Name Type Description columns
Array.<TableDataColumn> array of TableDataColumns
Example
tableData.setColumns([ {key: "Firma", label: "Firma", searchMode: "end", dataType: "string", searchCaseSensitive: true}, {key: "Kontaktperson", label: "Kontakt", dataType: "string", searchable: false}, {key: "Position", label: "Funktion", dataType: "string", searchable: false}, {key: "Ort", label: "Ort", dataType: "string", searchMode: "start", searchable: false}, {key: "Land", label: "Land", dataType: "string", searchable: false} ]);
-
inherited setContainerButtons(containerButtonConfigs)
-
Set the container buttons.
Please note that existing default buttons are removed by this operation.Name Type Description containerButtonConfigs
Array.<object> array of button config objects
Name Type Default Description id
string button id
label
string button label
clickFunction
string name of the client function to execute on click
disabled
boolean false optional - Since:
- Documents 5.0e
-
inherited setContextData(contextData)
-
Set additional data which is serialized with
JSON.stringify()
and then transferred to the client
On the client side the the context data is accessible with theGadgetContext
Name Type Description contextData
any the context data
- Since:
- Documents 5.0c
Example
var htmlGadget = new otris.gadget.gui.HTML("<h1>Only a simple example</h1>"); var myGadgetData = { mySpecialId: 44137, myIndexArray: [1,7,6,3,2], myTitle: "A special GadgetTitle" }; htmlGadget.setContextData(myGadgetData);
-
setDBConnection(dbConnection)
-
Sets the db connection which is used to excecute the database queries
Expects an instance of DBConnection class defined in the PortalScripting APIName Type Description dbConnection
DBConnection database connection
Example
// Add db connection var myDB = new DBConnection("odbc", "Nordwind"); tableData.setDBConnection(myDB);
-
setDetailsHandler(detailsHandler)
-
Set a callback function to handle the details data
Name Type Description detailsHandler
function callback function. The function is called with two parameters: items (array of detail data), mapping (the mapping added with setMapping)
Example
tableData.setDetailsHandler(function details(items, mapping) { alert(JSON.stringify(items, null, 2)); });
-
setDetailsSql(detailsSql)
-
Set the sql query to fetsch the details for the selected entries.
The query must contain a ? so the values of the defined key column could be added to the query
(The ? ist replaced by a comma seperated list of the key colum values).Name Type Description detailsSql
string sql select query with WHERE-clause
Example
tableData.setDetailsSql('SELECT * FROM Kunden WHERE "Kunden-Code" IN (?)');
-
setKeyColumn(keyColumn)
-
Set the key column for the list entries. The value of this column is used as a identifier for the entries.
For example the details query is called with this valuesName Type Description keyColumn
string key column
Example
tableData.setKeyColumn("Kunden-Code");
-
setListTitle(title)
-
Sets the title of the list (Display above the list)
Name Type Description title
string title of the list
-
setMapping(mappings)
-
Set a mapping to automatically fill file fields of the current map.
For example if the gadget is used a user-exitName Type Description mappings
Array.<TableDataMapping> Array of TableDataMappings
Example
tableData.setMapping([ { fieldName: "crmName", columnName: "Kontaktperson", valueCallback: function(value, documentsContext, item, mappingConfig) { return value.split(/\s+/)[1]; } }, { fieldName: "crmFirstName", columnName: "Kontaktperson", valueCallback: function(value, documentsContext) { return value.split(/\s+/)[0]; } }, {fieldName: "crmAccountnumber", columnName: "Kunden-Code"}, {fieldName: "crmCompany", columnName: "Firma"}, {fieldName: "crmPhone", columnName: "Telefon"} ]);
-
setMultiColumnSort(multiColumnSort)
-
Enable or disable multi column sorting
Name Type Description multiColumnSort
boolean enable or disable multi column sorting
-
setMultiSelect(multiSelect, buttonLabel, the)
-
Enable multi select
Name Type Description multiSelect
boolean Enable or disable multi select
buttonLabel
string label for the button to call the detailsHandler
the
function function to be executed if the button is clicked. See setDetailsHandler(detailsHandler) detailsHandler
-
inherited setNavibarEntry(gadgetConfig, label)
-
Add a navibar entry. Define a gadgetConfig that reloads the gadget.
Only works if the gadget ist displayed in main list view area.Name Type Description gadgetConfig
object gadgetConfig
label
string optional label for the navibar entry (defaults to the gadget title)
- Since:
- Documents 5.0e
-
setShowSearchBox(showSearchBox)
-
Enable the search box
Name Type Description showSearchBox
boolean show or hide the search box
-
setSqlEscapeFunction(escapeFunction)
-
Register your own escape function to prevent sql injection (Warning: Replaces the default implementation).
The function is called with 2 parameters: searchExpression and column (column definition, not always defined).
The returned value (string) is used in the sql query wrapped by single quotes so the escape function must escape those.Name Type Description escapeFunction
function the escape function
-
setSqlFilter(sqlFilter)
-
Sets a default filter for the select query (WHERE-clause used for the sql query to fetch the list entries).
Name Type Description sqlFilter
string sql WHERE-clause
Example
tableData.setSqlFilter("WHERE active = '1'");
-
setSqlSelect(sqlSelect)
-
Set the sql query used to fetch the list entries
Set only the simple query without WHERE- and ORDER-clause.
For default filtering entries use the setSqlFilter(sqlFilter) methodName Type Description sqlSelect
string sql select query
Example
tableData.setSqlSelect("SELECT * FROM Kunden");
-
inherited setStyle(name, value)
-
Sets a style attribute of the html container
Name Type Description name
string the name of the style parameter (i.e. "height")
value
string the value of the style parameter (i.e. "100px")
-
inherited setTitle(title)
-
Sets the Title of the Form
Name Type Description title
string the title of the form (will be displayed as the window header on dashboards)
-
inherited store(key, value)
-
Stores data that can later be accessed on client side.
ATTENTION: The store used in this method is global.
UsesetContextData
to store data for this gadget instance.Name Type Description key
string the key to store the data
value
any the value, or object that should be stored
-
inherited transfer()
-
Creates the Transfer object to send to the client