Advanced Table

Default (Required Props)

Year
New Enrollments
Scheduled Meetings
Attendance Rate
Completed Classes
Class Completion Rate
Graduated Students
2021
20
10
51%
3
33%
19
Q1
2
35
32%
15
52%
36
January
16
20
11%
13
47%
28
10
34
28
97%
20
15%
17
20
43
23
66%
26
47%
9
February
20
41
95%
26
83%
43
15
19
35
69%
8
75%
23
2022
25
17
75%
5
45%
32
Q1
2
35
32%
15
52%
36
January
16
20
11%
13
47%
28
15
34
28
97%
20
15%
17
25
43
23
66%
26
47%
9
May
20
41
95%
26
83%
43
2
19
35
69%
8
75%
23
2023
10
15
65%
4
49%
29
Q1
2
35
32%
15
52%
36
March
16
20
11%
13
47%
28
10
34
28
97%
20
15%
17
11
43
23
66%
26
47%
9
April
20
41
95%
26
83%
43
15
19
35
69%
8
75%
23

BETA VERSION
This kit's Rails version is currently under development. Some features may not work as expected, and breaking changes may still occur; use with caution.





The AdvancedTable kit accepts tree data and automatically renders expansion controls for nested subrows, to any depth, based on the data it is given. In it's simplest form, the kit has two required props:

table_data

table_data accepts an array of objects as the table data. Each object is a table row, and each key:value pair within an object is a column value within that row. Nested children within a data object are automatically rendered as subrows under their parent row.

For a visual of the data structure needed for table_data, see here.

column_definitions

Column definitions are the single most important part of building a table as they are responsible for building the underlying data model that is used for all sorting, expansion, etc. column_definitions in the AdvancedTable kit is an array of objects as seen in the code snippet below. Each object within the array has two REQUIRED items:

  • accessor: this is the key from your data for the value you want rendered in that column
  • label: this is what will be rendered as the column header label

There is also one optional item that is only required if the table has nested data:

  • cellAccessors: This is an array of strings that represent keys from your data object. This is only required for the first column in case of nested data. If you have nested data, the AdvancedTable needs to know what to render in that first column for nested items. This array represents the nested data in the order you want it rendered.
SubRow Headers

Year
New Enrollments
Scheduled Meetings
Attendance Rate
Completed Classes
Class Completion Rate
Graduated Students
2021
20
10
51%
3
33%
19
Quarter
Q1
2
35
32%
15
52%
36
Month
January
16
20
11%
13
47%
28
Day
10
34
28
97%
20
15%
17
20
43
23
66%
26
47%
9
February
20
41
95%
26
83%
43
Day
15
19
35
69%
8
75%
23
2022
25
17
75%
5
45%
32
Quarter
Q1
2
35
32%
15
52%
36
Month
January
16
20
11%
13
47%
28
Day
15
34
28
97%
20
15%
17
25
43
23
66%
26
47%
9
May
20
41
95%
26
83%
43
Day
2
19
35
69%
8
75%
23
2023
10
15
65%
4
49%
29
Quarter
Q1
2
35
32%
15
52%
36
Month
March
16
20
11%
13
47%
28
Day
10
34
28
97%
20
15%
17
11
43
23
66%
26
47%
9
April
20
41
95%
26
83%
43
Day
15
19
35
69%
8
75%
23

subrow_headers is an optional prop that if present will add header rows at each level of the nested data. The prop takes an array of strings, each string being the text for each header row. The array of strings must be in the order in which they need to be rendered in the UI according to depth.

enable_toggle_expansion is an additional optional prop that can be used in conjunction with the subRowHeaders prop. enable_toggle_expansion is a string that can be "all", "header" or "none". If set to "all", the toggle exapansion button will appear in the table header as well as in the subRow headers. If set to "header" button will only appear in header and NOT in subRow headers. This is set to "header" by default.

Enable Sorting

New Enrollments
Scheduled Meetings
Attendance Rate
Completed Classes
Class Completion Rate
Graduated Students
2021
20
10
51%
3
33%
19
Quarter
Q1
2
35
32%
15
52%
36
Month
January
16
20
11%
13
47%
28
Day
10
34
28
97%
20
15%
17
20
43
23
66%
26
47%
9
February
20
41
95%
26
83%
43
Day
15
19
35
69%
8
75%
23
2022
25
17
75%
5
45%
32
Quarter
Q1
2
35
32%
15
52%
36
Month
January
16
20
11%
13
47%
28
Day
15
34
28
97%
20
15%
17
25
43
23
66%
26
47%
9
May
20
41
95%
26
83%
43
Day
2
19
35
69%
8
75%
23
2023
10
15
65%
4
49%
29
Quarter
Q1
2
35
32%
15
52%
36
Month
March
16
20
11%
13
47%
28
Day
10
34
28
97%
20
15%
17
11
43
23
66%
26
47%
9
April
20
41
95%
26
83%
43
Day
15
19
35
69%
8
75%
23

Optionally enable sorting by passing sort_menu to any column_definition(s). Sort options are determined by an array of item objects passed to the sort_menu prop.


Disclaimer

This example uses a custom sort method that may need to be modified or replaced within your project.