I have below requirement. I only need to use oracle-jet oj-table:
- On page load organization data is loaded with different roles of employees. Need to bind this data to oj-table, with rows grouped on employee role (like manager, HR etc..)
- Row selection should be enabled with checkbox in first column. Single & multiple selection needed.
- Group header row should also have the checkbox, selecting which selects all the employees in that group.
Sample code or examples or any reference links are highly appriciated.
Thanks
There are plenty of example in Oracle JET cookbook on how to bind data to an
oj-table
.For checking one/all rows, here is one way to do it:
View:
Model:
If you have a button or something, you can then have a click callback where you can have your selected IDs by
const ids = self.selectedIDs();
.Note that there are probably better ways to do this, but, in summary:
selectedIds
in the example) and each of them having the ID of the entity represented by that row;Observable<boolean>
, subscribe to its value and update the value of all checkboxes with the above name (selectedIds
);EDIT: There is a Cookbook example for (multi)selection, which is waaaaay easier than my hacky approach.