AutoTable
You can gain access to the underlying Insight Table object and from that the DataTable object too.
Method summary
name | description |
---|---|
destroy | Destroy the AutoTable instance. This will destroy the underlying DataTable and remove any DOM from within the table. |
onDataSaved | Attach a data saved callback. |
Constructor
Create a new AutoTable instance using table referenced with passed in id.
Parameters:
Name | Type | Description |
---|---|---|
config | AutoTable~Config |
Members
- table - { Table }
-
The underlying Insight Table object.
Methods
- destroy ( remove )
-
Destroy the AutoTable instance. This will destroy the underlying DataTable and remove any DOM from within the table.
Parameters:
Name Type Argument Default Description remove boolean optional false Whether to remove the table element or just remove AutoTable handlers. If destroy is called before an update (to refresh the table data) you probably want to omit this parameter or set it to false. - onDataSaved ( callback )
-
Attach a callback that will be called on save of any element associated with this AutoTable instance.
Parameters:
Name Type Description callback AutoTable~DataSavedCallback Called when an entity has been successfully updated Example
Back to Topvar table = new insight.components.AutoTable(...); table.onDataSaved(function(scenario, entity, value) { console.log('table 1 data saved: ' + scenario.getId() + ' - ' + entity.getName() + ' - ', value); });
Type Definitions
- Add ( autotable ) → {boolean}
-
Callback function for AutoTable-Add. Overriding this behaviour will make it your responsibility to add the DOM elements representing the row to the AutoTable.
Parameters:
Name Type Description autotable AutoTable Table to which rows are to be added Returns:Type Description boolean Return true if the row was successfully added - ColumnOptions - { Object }
-
Data structure passed to AutoTable.
Properties:
Name Type Argument Default Description name string Name of the entity to use for this column scenario Scenario optional The scenario to use for this column. Falls back to the default scenario assigned to the table filters AutoTable~ColumnOptions~Filter optional A map of index entity name to fixed (filtered) value(s). If this column has more indices than the column with the least number of indices then you must give fixed values for the extra indices. sortByFormatted boolean optional false Use formatted values for sorting. This is ignored if you supply your own render function. filterByFormatted boolean optional Use formatted values for filtering. This defaults to false unless the entity has a label in which case the default is true. This is ignored if you supply your own render function. disableSetSorting boolean optional false When applied to an index column, this will prevent set sorting from being applied to the column. Default table sorting will be used instead. This option is provided to reduce sorting overhead where performance is being affected. title string optional Title for the table column. Defaults to entity alias then entity name width string optional CSS width value visible boolean optional true Show or hide the column. Defaults to visible. style string optional Element class for the column render Table~RenderCallback optional Callback to custom render the cell. Overrides any default entity rendering. editable boolean optional false Whether cells in this column are editable or not editorOptionsSet string optional Name of a set entity to use for select options. This will display labels if a labels entity is defined against this set. editorOptions Table~EditorOptionsCallback optional A function that returns either an array of primitive values to display or a map object of values and display text to use for the select options. selectNull boolean optional false Enables array elements to be removed using a blank option added to the top of the select input checkedValue * optional The value to set the cell data to if input type is checkbox and it is checked uncheckedValue * optional The value to set the cell data to if input type is checkbox and it is not checked editorValidate AutoTable~EditorValidateCallback optional A callback to validate each cell edit in this column editorType Table.EditorType optional The editor type to use, in edit mode, for cells in this column. If not specified then it will be autodetected based on entity type. - Config - { object }
-
Configuration object parameter for AutoTable.
Properties:
Name Type Argument Default Description tableId string DOM id of table element scenario Scenario The default scenario for all bound entities in the table selectionAndNavigation boolean optional true Enable/disable table navigation, selection and clipboard alwaysShowSelection boolean optional false Whether to display selection on inactive tables. addRemoveRow boolean | string optional false Enable the add/remove row feature. If you set this value to be the string 'addrow-autoinc' it will switch the behaviour to allow new index values to be created, incrementing from the highest value in the set. columnOptions Array.<AutoTable~ColumnOptions> optional indicesOptions Object.<string, (AutoTable~IndicesOptions|Array.<AutoTable~IndicesOptions>)> optional Map of set name to indices options overrides Object.<string, *> optional key-value pairs that are pass into the DataTables library, DataTables options reference Properties
Name Type Argument Default Description columnFilter boolean optional false Triggers column filters to be added to the table addRow AutoTable~Add optional Hook for replacement of entire functionality to add a row deleteRow AutoTable~Remove optional Hook for replacement of entire functionality to remove row preAdd AutoTable~RowCallback optional Hook for validation or other actions prior to adding a row preRemove AutoTable~RowCallback optional Hook for validation or other actions prior to removing a row postAdd AutoTable~RowCallback optional Hook for notification after a row has been added postRemove AutoTable~RowCallback optional Hook for notification after a row has been removed onDataSaved AutoTable~DataSavedCallback optional Hook for notification after data has been saved rowFilter AutoTable~RowFilterCallback optional Called for each row in the table to determine whether it should be kept or discarded saveState boolean optional true Save table state in user's browser session so that user settings (e.g. page, sorting and search) are preserved if table data is reloaded. - DataSavedCallback ( scenario, entity, value )
-
Callback for AutoTable#onDataSaved.
Parameters:
Name Type Description scenario Scenario The table column scenario entity ModelEntity The table column entity. Passes undefined if it is an Insight Parameter type value string | object Either a single value string or a composite key-value pair, in the case of an array) for the value saved. If removal of an array element then the value will be an empty string - EditorValidateCallback ( value, row, key ) → {Result}
-
Callback function for cell validation.
Parameters:
Name Type Description value PrimitiveType The new value from the edit. row Array.<PrimitiveType> An array of the underlying data from the row. key Array.<PrimitiveType> The row index tuple (ordered list of index sets values). Returns:Type Description Result The validation result as a validation object. Example
Back to Topfunction array1Validation(value, row, key) { var array2value = row[1]; var result = new insight.validation.Result(true); if(value < 100 && array2value === 'STRICT') { result.isValid = false; result.errorMessage = 'Must be less that 100 if corresponding Array2 is set to STRICT'; } // Build up a insight.validation.Result object with the validation outcome return result; } var table = new insight.components.AutoTable({ tableId: 'table-1', columnOptions: [ {name: 'Array1', editorValidate: array1Validation}, {name: 'Array2'}, ] });
- IndicesOptions - { Object }
-
Configuration for each Index set column AutoTable.
Properties:
Name Type Argument Default Description title string optional Custom title for the index column. style string optional Apply one or more css classes to the index column. render Table~RenderCallback optional Callback to custom render the cell. Overrides any default entity rendering. width width optional Specify the index column width rather than using auto width calculation. visible boolean optional true Show or hide the column. Defaults to visible. sortByFormatted boolean optional false Use formatted values for sorting. This is ignored if you supply your own render function. filterByFormatted boolean optional Use formatted values for filtering. This defaults to false unless the entity has a label in which case the default is true. This is ignored if you supply your own render function. format string optional Format string. - Remove ( rows )
-
Callback function for AutoTable-Remove. Overriding this behaviour will make it your responsibility to remove the row(s) from the AutoTable, this can be done using the DataTables API.
Parameters:
Name Type Argument Description rows DataTable.Api optional Rows to be removed from the table - RowCallback ( rowData ) → {boolean}
-
Callback function for pre- and post- Add/Remove row hooks.
Parameters:
Name Type Description rowData Array.<PrimitiveType> An array of the underlying data from the row Returns:Type Description boolean false if the operation to be aborted. Ignored for postAdd and postRemove actions. Example
Back to Topfunction preAddCallback(rowData) { // Don't allow a row with indices 1,2,3 to be added return rowData[0] !== 1 || rowData[1] !== 2 || rowData[2] !== 3; } function preRemoveCallback(rowData) { // Don't allow a row with indices 9,9,9 to be removed return rowData[0] !== 9 || rowData[1] !== 9 || rowData[2] !== 9; } function addRemoveNotify(action, rowData) { alert('row ' + action + '. ' + rowData.join(','); } var table = new insight.components.AutoTable({ tableId: 'table-1', ..., preAdd: preAddCallback, preRemove: preRemoveCallback, postAdd: addRemoveNotify.bind(table, 'add'), postRemove: addRemoveNotify.bind(table, 'remove') });
- RowFilterCallback ( rowData, indices ) → {boolean}
-
Callback function to filter table rows. Called for each row in the table. The return value determines whether a given row should be kept or discarded.
Parameters:
Name Type Description rowData Array.<PrimitiveType> Values for all cells within the row indices Array.<PrimitiveType> The indices of the row Returns:Type Description boolean true to keep the row, false to discard it Example
Back to Top// Only show rows where data adds up to 100 or more. function rowsGreaterEqual100(rowData, indices) { // Only add up the data cells, omitting the indices var total = rowData.slice(indices.length).reduce(function(memo, value) { return memo + value; }, 0); return total >= 100; } var table = new insight.components.AutoTable({ tableId: 'table-1', ..., rowFilter: rowsGreaterEqual100 });
© 2001-2024 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.