diff --git a/api-generator/components/datatable.js b/api-generator/components/datatable.js index 9cf87e0af..5108bc7c5 100644 --- a/api-generator/components/datatable.js +++ b/api-generator/components/datatable.js @@ -7,7 +7,7 @@ const DataTableProps = [ }, { name: "dataKey", - type: "string", + type: "string|function", default: "null", description: "Name of the field that uniquely identifies the a record in the data." }, diff --git a/src/components/datatable/DataTable.d.ts b/src/components/datatable/DataTable.d.ts index e44ec581e..36f291ce7 100755 --- a/src/components/datatable/DataTable.d.ts +++ b/src/components/datatable/DataTable.d.ts @@ -7,6 +7,8 @@ type DataTablePaginatorPositionType = 'top' | 'bottom' | 'both' | undefined; type DataTableSortFieldType = string | ((item: any) => string) | undefined; +type DataTableDataKeyType = string | (() => string) | undefined; + type DataTableMultiSortMetaType = DataTableSortMeta[] | undefined | null; type DataTableSortOrderType = 1 | 0 | -1 | undefined | null; @@ -465,8 +467,9 @@ export interface DataTableProps { value?: any[] | undefined; /** * Name of the field that uniquely identifies the a record in the data. + * @see DataTableDataKeyType */ - dataKey?: string | undefined; + dataKey?: DataTableDataKeyType; /** * Number of rows to display per page. */ diff --git a/src/components/datatable/DataTable.vue b/src/components/datatable/DataTable.vue index abb7f78ad..5d1371a4d 100755 --- a/src/components/datatable/DataTable.vue +++ b/src/components/datatable/DataTable.vue @@ -93,7 +93,7 @@ export default { default: null }, dataKey: { - type: String, + type: [String, Function], default: null }, rows: {