Skip to content

Commit

Permalink
fix(datagrid): doc with new props
Browse files Browse the repository at this point in the history
  • Loading branch information
aesteves60 committed Oct 3, 2023
1 parent 366fd77 commit d8851ab
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ export class OsdsDatagrid implements OdsDatagridAttribute {
this.table?.setData(rows);
}

@Watch('isSelectable')
@Watch('columns')
onChangeColumns(): void {
const columns = this.controler.getColumns();
this.table?.setColumns(this.controler.getTabulatorColumns(columns));
}

render(): JSX.Element {
return (
<Host>
Expand Down
39 changes: 39 additions & 0 deletions packages/components/datagrid/src/docs/osds-datagrid/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,43 @@ import GenericStyle from '@ovhcloud/ods-common-core/docs/generic-style.mdx';
{ name: "Garnbret", firstname: "Janja", gender: "female", dob: "12/03/1999" },
];
</script>
```

### Selectable columns
<osds-datagrid
columns='[{"title":"Name","field":"name"},{"title":"Firstname","field":"firstname"},{"title":"Gender","field":"gender"},{"title":"Date Of Birth","field":"dob"}]'
rows='[{"name":"Dupont","firstname":"Antoine","gender":"male","dob":"15/11/1996"},{"name":"Garnbret","firstname":"Janja","gender":"female","dob":"12/03/1999"}]'
is-selectable>
</osds-datagrid>

```html
<!-- Attributes need to be stringify -->
<osds-datagrid
columns='[{"title":"Name","field":"name"},{"title":"Firstname","field":"firstname"},{"title":"Gender","field":"gender"},{"title":"Date Of Birth","field":"dob"}]'
rows='[{"name":"Dupont","firstname":"Antoine","gender":"male","dob":"15/11/1996"},{"name":"Garnbret","firstname":"Janja","gender":"female","dob":"12/03/1999"}]'
is-selectable>
</osds-datagrid>
```
### With sortable columns
<osds-datagrid
columns='[{"title":"Name","field":"name", "isSortable": true},{"title":"Firstname","field":"firstname"},{"title":"Gender","field":"gender"},{"title":"Date Of Birth","field":"dob"}]'
rows='[{"name":"Dupont","firstname":"Antoine","gender":"male","dob":"15/11/1996"},{"name":"Garnbret","firstname":"Janja","gender":"female","dob":"12/03/1999"}]'>
</osds-datagrid>

```html
<osds-datagrid id="datagrid"></osds-datagrid>

<script>
const datagrid = document.querySelector('#datagrid')
datagrid.columns = [
{ title: "Name", field: "name", isSortable: true },
{ title: "Firstname", field: "firstname" },
{ title: "Gender", field: "gender" },
{ title: "Date Of Birth", field: "dob" },
];
datagrid.rows = [
{ name: "Dupont", firstname: "Antoine", gender: "male", dob: "15/11/1996" },
{ name: "Garnbret", firstname: "Janja", gender: "female", dob: "12/03/1999" },
];
</script>
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import page from './datagrid.web-component.stories.page.mdx';

defineCustomElements();

/* Default story parameters */
/* Default story parameters */
const defaultStoryParams = {
columns: {
category: 'Général',
defaultValue: [
{ title: "Name", field: "name" },
{ title: "Name", field: "name", isSortable: true },
{ title: "Firstname", field: "firstname" },
{ title: "Gender", field: "gender" },
{ title: "Date Of Birth", field: "dob" },
Expand All @@ -26,6 +26,10 @@ const defaultStoryParams = {
{ name: "Garnbret", firstname: "Janja", gender: "female", dob: "12/03/1999" },
],
},
isSelectable: {
category: 'Général',
defaultValue: false
},
};

export default {
Expand Down

0 comments on commit d8851ab

Please sign in to comment.