mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2764] Applied new doc tool features to core library (#3383)
This commit is contained in:
committed by
Eugenio Romano
parent
5831bc1d77
commit
41777e0540
@@ -2,6 +2,7 @@
|
||||
Added: v2.0.0
|
||||
Status: Active
|
||||
---
|
||||
|
||||
# DataTableAdapter interface
|
||||
|
||||
Defines how table data is supplied to [DataTable](datatable.component.md)
|
||||
@@ -10,17 +11,17 @@ and [Tasklist](../process-services/task-list.component.md) components.
|
||||
## Properties
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| ---- | ---- | ----------- |
|
||||
| selectedRow | DataRow | The data for the currently selected row. |
|
||||
|
||||
## Methods
|
||||
|
||||
`getRows(): Array<DataRow>;`<br/>
|
||||
`setRows(rows: Array<DataRow>): void;`<br/>
|
||||
[`getRows(): Array<DataRow>;`](../../lib/core/datatable/data/data-row.model.ts)<br/>
|
||||
[`setRows(rows: Array<DataRow>): void;`](../../lib/core/datatable/data/data-row.model.ts)<br/>
|
||||
Get/set the values for display in the table using an array of rows.
|
||||
|
||||
`getColumns(): Array<DataColumn>;`<br/>
|
||||
`setColumns(columns: Array<DataColumn>): void;`<br/>
|
||||
[`getColumns(): Array<DataColumn>;`](../../lib/core/datatable/data/data-column.model.ts)<br/>
|
||||
[`setColumns(columns: Array<DataColumn>): void;`](../../lib/core/datatable/data/data-column.model.ts)<br/>
|
||||
Get/set an array of column specifications.
|
||||
|
||||
`getValue(row: DataRow, col: DataColumn): any;`<br/>
|
||||
@@ -33,25 +34,24 @@ Get/set the sorting key and direction (ascending or descending).
|
||||
`sort(key?: string, direction?: string): void;`
|
||||
Sort the table with a specified key and direction (ascending or descending).
|
||||
|
||||
|
||||
## Details
|
||||
|
||||
You can implement DataTableAdapter in your own class to display your data with the [DataTable](datatable.component.md)
|
||||
You can implement [`DataTableAdapter`](../../lib/core/datatable/data/datatable-adapter.ts) in your own class to display your data with the [DataTable](datatable.component.md)
|
||||
and [Tasklist](../process-services/task-list.component.md) components.
|
||||
This interface (along with other interfaces for column and row data) hides the details of your class from the caller, so you can store your data internally however you like. The DataTable library implements the interface in the [ObjectDataTableAdapter](#objectdatatableadapter) class which is the standard adapter for the Datatable component.
|
||||
This interface (along with other interfaces for column and row data) hides the details of your class from the caller, so you can store your data internally however you like. The DataTable library implements the interface in the [`ObjectDataTableAdapter`](../../lib/core/datatable/data/object-datatable-adapter.ts) class which is the standard adapter for the Datatable component.
|
||||
|
||||
The basic idea of DataTableAdapter is that the caller can request your class to return an array of column
|
||||
The basic idea of [`DataTableAdapter`](../../lib/core/datatable/data/datatable-adapter.ts) is that the caller can request your class to return an array of column
|
||||
definition objects. Each of these objects specifies the unique key, name, type and other properties of a single column.
|
||||
|
||||
The caller can also request the data values for the table as an array of row objects. The caller accesses the data from a row using a `getValue` method that returns the data from a specified column. This column is identified by the unique key that was set during the column definition.
|
||||
|
||||
The data-hiding works the other way around when the caller needs to set data in the DataTableAdapter class - the internal
|
||||
The data-hiding works the other way around when the caller needs to set data in the [`DataTableAdapter`](../../lib/core/datatable/data/datatable-adapter.ts) class - the internal
|
||||
details of the caller's storage are hidden by the column and row interfaces. When the `setColumns` and `setRows` methods are
|
||||
called on the adapter, it can simply query the column/row objects it receives and then store the data in its own format.
|
||||
|
||||
### Columns and rows
|
||||
|
||||
Columns are defined by the DataColumn interface:
|
||||
Columns are defined by the [`DataColumn`](../../lib/core/datatable/data/data-column.model.ts) interface:
|
||||
|
||||
```ts
|
||||
interface DataColumn {
|
||||
@@ -69,7 +69,7 @@ interface DataColumn {
|
||||
|
||||
An array of these objects is passed to your object when the `setColumns` method is called. The `key` property is used to identify columns and so each column's key should be unique. The `type` string can have a value of 'text', 'image' or 'date'.
|
||||
|
||||
An array of DataRow objects is passed to your object when the `setRows` method is called:
|
||||
An array of [`DataRow`](../../lib/core/datatable/data/data-row.model.ts) objects is passed to your object when the `setRows` method is called:
|
||||
|
||||
```ts
|
||||
interface DataRow {
|
||||
@@ -85,8 +85,8 @@ Each row contains a set of values. An item in the set is retrieved by passing it
|
||||
|
||||
### ObjectDataTableAdapter
|
||||
|
||||
The DataTable library provides a implementation of DataTableAdapter, called
|
||||
[ObjectDataTableAdapter](https://github.com/Alfresco/alfresco-ng2-components/blob/master/ng2-components/ng2-alfresco-datatable/src/data/object-datatable-adapter.ts). This is a simple adapter that binds to object arrays and turns object fields into columns:
|
||||
The DataTable library provides a implementation of [DataTableAdapter,](../../lib/core/datatable/data/datatable-adapter.ts) called
|
||||
[`ObjectDataTableAdapter`](../../lib/core/datatable/data/object-datatable-adapter.ts). This is a simple adapter that binds to object arrays and turns object fields into columns:
|
||||
|
||||
```ts
|
||||
let data = new ObjectDataTableAdapter(
|
||||
@@ -143,13 +143,14 @@ let schema = ObjectDataTableAdapter.generateSchema(data);
|
||||
}
|
||||
]
|
||||
*/
|
||||
|
||||
```
|
||||
|
||||
<!-- Don't edit the See also section. Edit seeAlsoGraph.json and run config/generateSeeAlso.js -->
|
||||
|
||||
<!-- seealso start -->
|
||||
|
||||
## See also
|
||||
|
||||
- [Datatable component](datatable.component.md)
|
||||
- [Task list component](../process-services/task-list.component.md)
|
||||
<!-- seealso end -->
|
||||
- [Datatable component](datatable.component.md)
|
||||
- [Task list component](../process-services/task-list.component.md)
|
||||
<!-- seealso end -->
|
||||
|
Reference in New Issue
Block a user