UNPKG

presentation-table

Version:

The Augmented.js Next - Presentation Table View Module.

641 lines (393 loc) 16.9 kB
# presentation-table Augmented.js Presentation Table View Module # API <!-- Generated by documentation.js. Update this documentation by updating the source code. --> ### Table of Contents - [AutomaticTable](#automatictable) - [Parameters](#parameters) - [Examples](#examples) - [theme](#theme) - [Properties](#properties) - [linkable](#linkable) - [Properties](#properties-1) - [links](#links) - [Properties](#properties-2) - [Examples](#examples-1) - [selectable](#selectable) - [Properties](#properties-3) - [sortable](#sortable) - [Properties](#properties-4) - [sortStyle](#sortstyle) - [Properties](#properties-5) - [display](#display) - [Properties](#properties-6) - [renderPaginationControl](#renderpaginationcontrol) - [Properties](#properties-7) - [paginationAPI](#paginationapi) - [Properties](#properties-8) - [description](#description) - [Properties](#properties-9) - [localStorage](#localstorage) - [Properties](#properties-10) - [localStorageKey](#localstoragekey) - [Properties](#properties-11) - [editable](#editable) - [Properties](#properties-12) - [crossOrigin](#crossorigin) - [Properties](#properties-13) - [lineNumbers](#linenumbers) - [Properties](#properties-14) - [uri](#uri) - [Properties](#properties-15) - [isInitalized](#isinitalized) - [Properties](#properties-16) - [pageControlBound](#pagecontrolbound) - [Properties](#properties-17) - [schema](#schema) - [Properties](#properties-18) - [name](#name) - [Properties](#properties-19) - [setTheme](#settheme) - [Parameters](#parameters-1) - [rowLink](#rowlink) - [Parameters](#parameters-2) - [sortBy](#sortby) - [Parameters](#parameters-3) - [currentPage](#currentpage) - [totalPages](#totalpages) - [nextPage](#nextpage) - [previousPage](#previouspage) - [goToPage](#gotopage) - [Parameters](#parameters-4) - [firstPage](#firstpage) - [lastPage](#lastpage) - [editCell](#editcell) - [Parameters](#parameters-5) - [copyCell](#copycell) - [Parameters](#parameters-6) - [clearCell](#clearcell) - [Parameters](#parameters-7) - [render](#render) - [retrieveSchema](#retrieveschema) - [Parameters](#parameters-8) - [fetch](#fetch) - [save](#save) - [Parameters](#parameters-9) - [populate](#populate) - [Parameters](#parameters-10) - [clear](#clear) - [refresh](#refresh) - [compileTemplate](#compiletemplate) - [setURI](#seturi) - [Parameters](#parameters-11) - [setSchema](#setschema) - [Parameters](#parameters-12) - [showProgressBar](#showprogressbar) - [Parameters](#parameters-13) - [showMessage](#showmessage) - [Parameters](#parameters-14) - [validate](#validate) - [isValid](#isvalid) - [remove](#remove) - [getSelected](#getselected) - [Parameters](#parameters-15) - [getSelectedAsJSON](#getselectedasjson) - [getSelectedIndex](#getselectedindex) - [removeRows](#removerows) - [Parameters](#parameters-16) - [removeSelectedRows](#removeselectedrows) - [addRow](#addrow) - [Parameters](#parameters-17) - [exportTo](#exportto) - [Parameters](#parameters-18) - [BigDataTable](#bigdatatable) - [Parameters](#parameters-19) - [EditableBigDataTable](#editablebigdatatable) - [Parameters](#parameters-20) - [EditableLocalStorageTable](#editablelocalstoragetable) - [Parameters](#parameters-21) - [EditableTable](#editabletable) - [Parameters](#parameters-22) - [LocalStorageTable](#localstoragetable) - [Parameters](#parameters-23) - [Spreadsheet](#spreadsheet) - [Parameters](#parameters-24) - [\_generate](#_generate) - [\_generate](#_generate-1) ## AutomaticTable **Extends DecoratorView** AutomaticTable<br/> Creates a table automatically via a schema for defintion and a uri/json for data ### Parameters - `options` (optional, default `{}`) ### Examples ```javascript const at = new AutomaticTable({ schema: schema, el: "#autoTable", crossOrigin: false, sortable: true, lineNumbers: true, editable: true, uri: "/example/data/table.json", messagePosition: "top", // or bottom theme: "material", linkable: true, links: { wholeRow: true, column: "", link: "rowLink" }, fetchOnStart: false }); ``` ### theme The theme property - The theme of this table (default is 'material') #### Properties - `theme` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The theme of this table ### linkable The linkable property - enable links in a row (only works in non-editable tables) #### Properties - `linkable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** enable/disable linking a row ### links The links property - setup linking structure for links in a row #### Properties - `linkable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** enable/disable linking a row #### Examples ```javascript links: { wholeRow: false, // link whole row vs column column: "name", // name of column link: "rowLink" // callback or method in class } ``` ### selectable The selectable property - enable selecting a row in table #### Properties - `selectable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** enable/disable selecting a row ### sortable The sortable property - enable sorting in table #### Properties - `sortable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** enable sorting in the table ### sortStyle The sortStyle property - setup the sort API #### Properties - `sortStyle` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** setup the sort API ### display Fields to display - null will display all #### Properties - `display` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** Fields to display ### renderPaginationControl The renderPaginationControl property - render the pagination control #### Properties - `renderPaginationControl` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** render the pagination control ### paginationAPI The paginationAPI property - setup the paginatin API to use #### Properties - `paginationAPI` **PaginationFactory.type** the pagination API to use ### description The description property #### Properties - `description` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The description of the table ### localStorage The localStorage property - enables localStorage #### Properties - `localStorage` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** The localStorage property ### localStorageKey The localStorageKey property - set the key for use in storage #### Properties - `localStorageKey` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The localStorage key property ### editable The editable property - enables editing of cells #### Properties - `editable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** The editable property ### crossOrigin The crossOrigin property - enables cross origin fetch #### Properties - `crossOrigin` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** The crossOrigin property ### lineNumbers The lineNumber property - turns on line numbers #### Properties - `lineNumbers` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** The lineNumbers property ### uri The URI property #### Properties - `uri` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The URI property ### isInitalized The initialized property #### Properties - `isInitalized` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** The initialized property ### pageControlBound The pageControlBound property #### Properties - `pageControlBound` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** is the pagecontrol bound ### schema The schema property - the defining schema #### Properties - `schema` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The schema ### name The name property #### Properties - `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The name of the table ### setTheme The theme of the table #### Parameters - `theme` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the theme ### rowLink The default rowlink function callback called by row to format a link #### Parameters - `row` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** The row data Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Returns the link uri ### sortBy Sort the table by a key (sent via a UI Event) #### Parameters - `key` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The key to sort by ### currentPage Return the current page number Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The current page number ### totalPages Return the total pages Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The total pages ### nextPage Advance to the next page ### previousPage Return to the previous page ### goToPage Go to a specific page #### Parameters - `page` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The page to go to ### firstPage Return to the first page ### lastPage Advance to the last page ### editCell Edit a cell at the row and column specified #### Parameters - `row` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The row - `col` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The column - `value` **any** The value to set ### copyCell Copy a cell at the row and column to another #### Parameters - `row1` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The 'from' row - `col1` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The 'from' column - `row2` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The 'to' row - `col2` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The 'to' column ### clearCell Clear a cell at the row and column specified #### Parameters - `row` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The row - `col` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The column ### render Render the table Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Returns the view context ('this') ### retrieveSchema Fetch the schema from the source URI #### Parameters - `uri` {string} the URI to fetch from ### fetch Fetch the data from the source URI ### save Save the data to the source This only functions if the table is editable #### Parameters - `override` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Save even if not editable Returns **any** Returns true if succesfull ### populate Populate the data in the table #### Parameters - `source` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** The source data array ### clear Clear all the data in the table ### refresh - **See: AutomaticTable.render ** Refresh the table (Same as render) Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Returns the view context ('this') ### compileTemplate An overridable template compile Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Returns the template ### setURI Sets the URI #### Parameters - `uri` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The URI ### setSchema Sets the schema #### Parameters - `schema` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The JSON schema of the dataset ### showProgressBar Enable/Disable the progress bar #### Parameters - `show` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Show or Hide the progress bar ### showMessage Show a message related to the table #### Parameters - `message` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Some message to display ### validate Validate the table Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Returns true on success of validation ### isValid Is the table valid Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Returns true if valid ### remove Remove the table and all binds Returns **any** Returns the context (this) ### getSelected Gets the selected models #### Parameters - `json` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** convert to array of objects Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** Returns array of selected rows (models) ### getSelectedAsJSON Gets the selected models as JSON Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** Returns array of selected rows (JSON Objects) ### getSelectedIndex Gets the selected row indexes Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** Returns array of selected rows (indexes) ### removeRows Removes the models #### Parameters - `rows` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** Models of the rows to remove ### removeSelectedRows Removes the selected models ### addRow adds a row to the table #### Parameters - `model` **Model** The model to add ### exportTo Export the table data in requested format #### Parameters - `type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The type requested (csv, tsv, json, or html) html is default Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The table data in requested format ## BigDataTable **Extends AutomaticTable** Instance class preconfigured for sorting and pagination ### Parameters - `options` ## EditableBigDataTable **Extends AutomaticTable** Instance class preconfigured for sorting and pagination ### Parameters - `options` ## EditableLocalStorageTable **Extends AutomaticTable** Instance class preconfigured for editing, sorting, from local storage ### Parameters - `options` ## EditableTable **Extends AutomaticTable** Instance class preconfigured for editing ### Parameters - `options` ## LocalStorageTable **Extends AutomaticTable** Instance class preconfigured for local storage-based table ### Parameters - `options` ## Spreadsheet **Extends AutomaticTable** Instance class preconfigured for editing for use as a Spreadsheet.<br/> If a propery for length is not specified, it will buffer 10 lines for editing. ### Parameters - `options` ### \_generate ### \_generate