diff --git a/packages/components/src/components/data-grid/data-grid.tsx b/packages/components/src/components/data-grid/data-grid.tsx index 01555e2846..7a09e24ac1 100644 --- a/packages/components/src/components/data-grid/data-grid.tsx +++ b/packages/components/src/components/data-grid/data-grid.tsx @@ -107,7 +107,15 @@ export class DataGrid { @Prop() styles: any; /** (optional) Set to false to hide table, used for nested tables to re-render upon toggle */ @Prop() visible?: boolean = true; - + /** + * (optional) set localization for sort, toggle and select/deselect table + * Default is English. + */ + @Prop() localization?: { + sortBy: string; + toggle: string; + select: string; + }; /* 4. Events (alphabetical) */ /** Event triggered every time the editable cells are changed, updating the original rows data */ @Event({ eventName: 'scale-edit' }) @@ -767,7 +775,7 @@ export class DataGrid { onClick={this.handleMenuListClick} > - Sort By + {this.localization?.sortBy || 'Sort By'} {this.fields.map( ( @@ -819,7 +827,7 @@ export class DataGrid { onClick={this.handleMenuListClick} > - Toggle Visibility + {this.localization?.toggle || 'Toggle Visibility'} - Select / Deselect All + {this.localization?.select || 'Select / Deselect All'} )} diff --git a/packages/components/src/components/data-grid/readme.md b/packages/components/src/components/data-grid/readme.md index 2a319f6b66..8347285c54 100644 --- a/packages/components/src/components/data-grid/readme.md +++ b/packages/components/src/components/data-grid/readme.md @@ -5,24 +5,25 @@ ## Properties -| Property | Attribute | Description | Type | Default | -| ---------------- | ----------------- | -------------------------------------------------------------------------------------------- | ---------- | ----------- | -| `fields` | `fields` | Input fields config array | `any` | `undefined` | -| `freezeHeader` | `freeze-header` | (optional) Freeze header row from scrolling | `boolean` | `false` | -| `heading` | `heading` | (optional) Heading string | `string` | `''` | -| `height` | `height` | (optional) Set static table height, by default will auto-resize | `string` | `undefined` | -| `hideBorder` | `hide-border` | (optional) Set to true to remove border | `boolean` | `false` | -| `hideHeader` | `hide-header` | (optional) Set to true to hide header row | `boolean` | `false` | -| `hideInfo` | `hide-info` | (optional) Set to true to remove info footer block including pagination and selection status | `boolean` | `false` | -| `hideMenu` | `hide-menu` | (optional) Set to true to hide settings menu | `boolean` | `false` | -| `numbered` | `numbered` | (optional) Set to true to add numbers column | `boolean` | `false` | -| `pageSize` | `page-size` | (optional) Set number of rows to display per pagination page | `number` | `Infinity` | -| `rows` | `rows` | Input data array | `any` | `undefined` | -| `selectable` | `selectable` | (optional) Set to true to add selection column | `boolean` | `false` | -| `selection` | -- | Read-only selection array - populated with raw data from selected rows | `string[]` | `[]` | -| `shadeAlternate` | `shade-alternate` | (optional) Shade every second row darker | `boolean` | `true` | -| `styles` | `styles` | (optional) Injected css styles | `any` | `undefined` | -| `visible` | `visible` | (optional) Set to false to hide table, used for nested tables to re-render upon toggle | `boolean` | `true` | +| Property | Attribute | Description | Type | Default | +| ---------------- | ----------------- | -------------------------------------------------------------------------------------------- | ----------------------------------------------------- | ----------- | +| `fields` | `fields` | Input fields config array | `any` | `undefined` | +| `freezeHeader` | `freeze-header` | (optional) Freeze header row from scrolling | `boolean` | `false` | +| `heading` | `heading` | (optional) Heading string | `string` | `''` | +| `height` | `height` | (optional) Set static table height, by default will auto-resize | `string` | `undefined` | +| `hideBorder` | `hide-border` | (optional) Set to true to remove border | `boolean` | `false` | +| `hideHeader` | `hide-header` | (optional) Set to true to hide header row | `boolean` | `false` | +| `hideInfo` | `hide-info` | (optional) Set to true to remove info footer block including pagination and selection status | `boolean` | `false` | +| `hideMenu` | `hide-menu` | (optional) Set to true to hide settings menu | `boolean` | `false` | +| `localization` | -- | (optional) set localization for sort, toggle and select/deselect table Default is English. | `{ sortBy: string; toggle: string; select: string; }` | `undefined` | +| `numbered` | `numbered` | (optional) Set to true to add numbers column | `boolean` | `false` | +| `pageSize` | `page-size` | (optional) Set number of rows to display per pagination page | `number` | `Infinity` | +| `rows` | `rows` | Input data array | `any` | `undefined` | +| `selectable` | `selectable` | (optional) Set to true to add selection column | `boolean` | `false` | +| `selection` | -- | Read-only selection array - populated with raw data from selected rows | `string[]` | `[]` | +| `shadeAlternate` | `shade-alternate` | (optional) Shade every second row darker | `boolean` | `true` | +| `styles` | `styles` | (optional) Injected css styles | `any` | `undefined` | +| `visible` | `visible` | (optional) Set to false to hide table, used for nested tables to re-render upon toggle | `boolean` | `true` | ## Events diff --git a/packages/storybook-vue/stories/components/data-grid/DataGrid.stories.mdx b/packages/storybook-vue/stories/components/data-grid/DataGrid.stories.mdx index ed5d9d230e..83fb575a9f 100644 --- a/packages/storybook-vue/stories/components/data-grid/DataGrid.stories.mdx +++ b/packages/storybook-vue/stories/components/data-grid/DataGrid.stories.mdx @@ -99,6 +99,13 @@ import ScaleDataGrid from './ScaleDataGrid.vue'; description: `(optional) Set to true to add selection column`, control: { type: null }, }, + localization: { + table: { + type: { summary: 'object' }, + }, + description: `(optional) localization object for sort by, toogle visibility and select/deselect all. The default value is English`, + control: { type: null }, + }, shadeAlternate: { table: { type: { summary: 'boolean' }, @@ -228,6 +235,11 @@ export const Template = (args, {}) => ({ [4, 'Heidi', '3:15'], [5, 'Muhammad', '21:45'], ]; + dataGrid.localization = { + sortBy: 'Sort By', + toggle: 'Toogle Visibility', + select: 'Select / Deselect All' + } } `}