Skip to content

Commit d41daa2

Browse files
sbcguambtools
andauthored
Docs for new table features (#225)
Co-authored-by: Marc Bernard <[email protected]>
1 parent 97dde33 commit d41daa2

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed
107 KB
Loading

src/development-guide/user-interface/developing-ui-tables.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,17 @@ Finally, call the table `render` method to produce html. Pass the data table to
7474

7575
![Simplest table](/img/ui_table_simple.png)
7676

77+
## 2-level header
78+
79+
You can create groups of columns with `define_column_group`. See an example in `zcl_abapgit_gui_page_whereused` class. `title` and `id` are both options, but you have to start before the first column if you plan to use groups (because it calculates spans from start).
80+
81+
![2-level header](/img/ui_table_2_level_head.png)
82+
7783
## CSS styles
7884

7985
There are several options to styling your table:
8086

81-
- First, you can pass the element id, and css class of the table itself to the `render` method.
87+
- First, you can pass the element id, and css class of the table itself to the `render` method.
8288
- Passing `iv_wrap_in_div` parameter will wrap your table in another `div` with the given css class name, primarily for visual styling purposes (e.g. see padded borders and rounded corners in the screenshot below).
8389

8490
There are default CSS styles in abapGit to reuse if you don't want to bother with any specific styling - `default-table` and `default-table-container`, respectively, for the wrapping `div`.
@@ -153,6 +159,8 @@ table td[data-cid="id"] { font-weight: bold; }
153159
table tr[data-kind="error"] { background-color: red; }
154160
```
155161

162+
If you use 2-level header and pass `iv_group_id` it will also appear as a `data-gid` attribute in all relevant cells.
163+
156164
## Cell rendering
157165

158166
You can define your column so that the `column_id` and the field to take a value from have different names. In the example below the `iv_value` in `render_cell` will be taken from the `person_id` field in the table structure.
@@ -203,3 +211,30 @@ Technical-wise sorting markers are links with events defined like `sapevent:sort
203211
```
204212

205213
... and then applying the `ms_sorting_state` elsewhere before rendering the table
214+
215+
### In-table sorting
216+
217+
This feature is **experimental**, use with care. See `zcl_abapgit_gui_page_whereused` as an example.
218+
219+
To simplify sorting handling you may create your table component as a class member, and pass `is_initial_sorting_state`.
220+
221+
```abap
222+
DATA ls_sorting_state TYPE zif_abapgit_html_table=>ty_sorting_state.
223+
ls_sorting_state-column_id = 'xyz'.
224+
mi_table = zcl_abapgit_html_table=>create(
225+
is_initial_sorting_state = ls_sorting_state ).
226+
```
227+
228+
In the event handling method use `process_sorting_request` instead of `detect_sorting_request`.
229+
230+
```abap
231+
IF mi_table->process_sorting_request( ii_event->mv_action ) = abap_true.
232+
rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render.
233+
RETURN.
234+
ENDIF.
235+
```
236+
237+
With this approach you will not need any other sorting logic to implement the table component will handle sorting for you. Please mind the caveats though:
238+
239+
- The `column_id` (or supplied `from_field`) **must** exist as a table field (for sortable columns)
240+
- To do the sorting the component creates a copy of the data internally. Mind memory consumption.

0 commit comments

Comments
 (0)