Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ngx-table): Stringify the selectableKey value #239

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/table/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ As always, this default icon can be overwritten on table level by using the `sor

Another built-in common use case provided by the package is selecting rows. The `ngx-table` component functions as a control value accessor, which means any form control can be attached to the table. By setting the `selectable` property to true, the table will automatically display a checkbox at the start of every row, including a checkbox at the top of the headers to provide a select-all behavior.

By default, the `ngx-table` will use the index as the selected value in the form. If we wish to use a property of the data object instead, we can pass the key of the property to the `selectableKey` Input. Just as in previous use-cases, the default template of the checkbox can be overwritten by a custom template using the `checkboxTmpl`.
By default, the `ngx-table` will use the index as the selected value in the form. If we wish to use a property of the data object instead, we can pass the key of the property to the `selectableKey` Input. The value of this key should **always** be of type string or number. Just as in previous use-cases, the default template of the checkbox can be overwritten by a custom template using the `checkboxTmpl`.

```html
<ngx-table
Expand Down
2 changes: 1 addition & 1 deletion libs/table/src/lib/table/ngx-table.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
[ngxTreeGridRowSelectable]="selectable"
[ngxTreeGridRowExpanded]="openRows.has(rowIndex)"
[attr.aria-selected]="
rowsFormGroup.get(selectableKey ? data[rowIndex][selectableKey] : '' + rowIndex)?.value
rowsFormGroup.get(selectableKey ? '' + data[rowIndex][selectableKey] : '' + rowIndex)?.value
"
(ngxTreeGridRowSelectRow)="selectRow(rowIndex)"
(ngxTreeGridRowExpandRow)="handleRowState(rowIndex, $event ? 'open' : 'close')"
Expand Down