mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 12:20:51 +08:00
Empty tables in HTML forms (#4658)
Previously if there were no data rows, it would render just the column headers of the table. After this change, it shows "Not available". Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
parent
1104c88e48
commit
18c9b404f1
|
@ -631,10 +631,10 @@ CLASS zcl_abapgit_html_form IMPLEMENTATION.
|
||||||
METHOD render_field_table.
|
METHOD render_field_table.
|
||||||
|
|
||||||
DATA:
|
DATA:
|
||||||
lv_value TYPE string,
|
lv_value TYPE string,
|
||||||
lv_readonly TYPE string,
|
lv_readonly TYPE string,
|
||||||
lv_rows TYPE i,
|
lv_rows TYPE i,
|
||||||
lv_cell_id TYPE string.
|
lv_cell_id TYPE string.
|
||||||
|
|
||||||
FIELD-SYMBOLS <ls_subitem> LIKE LINE OF is_field-subitems.
|
FIELD-SYMBOLS <ls_subitem> LIKE LINE OF is_field-subitems.
|
||||||
|
|
||||||
|
@ -644,44 +644,52 @@ CLASS zcl_abapgit_html_form IMPLEMENTATION.
|
||||||
ii_html->add( is_attr-error ).
|
ii_html->add( is_attr-error ).
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
ii_html->add( |<table name="{ is_field-name }" id="{ is_field-name }" class="table-container">| ).
|
|
||||||
|
|
||||||
ii_html->add( |<thead>| ).
|
|
||||||
ii_html->add( |<tr>| ).
|
|
||||||
LOOP AT is_field-subitems ASSIGNING <ls_subitem>.
|
|
||||||
CLEAR lv_value.
|
|
||||||
IF <ls_subitem>-value IS NOT INITIAL.
|
|
||||||
lv_value = escape( val = <ls_subitem>-value
|
|
||||||
format = cl_abap_format=>e_html_attr ).
|
|
||||||
lv_value = | width="{ lv_value }"|.
|
|
||||||
ENDIF.
|
|
||||||
ii_html->add( |<td{ lv_value }>{ <ls_subitem>-label }</td>| ).
|
|
||||||
ENDLOOP.
|
|
||||||
ii_html->add( |</tr>| ).
|
|
||||||
ii_html->add( |</thead>| ).
|
|
||||||
|
|
||||||
lv_rows = io_values->get( |{ is_field-name }-{ zif_abapgit_html_form=>c_rows }| ).
|
lv_rows = io_values->get( |{ is_field-name }-{ zif_abapgit_html_form=>c_rows }| ).
|
||||||
|
|
||||||
ii_html->add( |<tbody>| ).
|
" Render table only if there are some data rows
|
||||||
DO lv_rows TIMES.
|
IF lv_rows > 0.
|
||||||
lv_rows = sy-index.
|
|
||||||
|
ii_html->add( |<table name="{ is_field-name }" id="{ is_field-name }" class="table-container">| ).
|
||||||
|
|
||||||
|
ii_html->add( |<thead>| ).
|
||||||
ii_html->add( |<tr>| ).
|
ii_html->add( |<tr>| ).
|
||||||
LOOP AT is_field-subitems ASSIGNING <ls_subitem>.
|
LOOP AT is_field-subitems ASSIGNING <ls_subitem>.
|
||||||
lv_cell_id = |{ is_field-name }-{ lv_rows }-{ sy-tabix }|.
|
CLEAR lv_value.
|
||||||
lv_value = escape( val = io_values->get( lv_cell_id )
|
IF <ls_subitem>-value IS NOT INITIAL.
|
||||||
format = cl_abap_format=>e_html_attr ).
|
lv_value = escape( val = <ls_subitem>-value
|
||||||
CLEAR lv_readonly.
|
format = cl_abap_format=>e_html_attr ).
|
||||||
IF <ls_subitem>-readonly = abap_true.
|
lv_value = | width="{ lv_value }"|.
|
||||||
lv_readonly = | readonly|.
|
|
||||||
ENDIF.
|
ENDIF.
|
||||||
ii_html->add( |<td><input type="text" name="{ lv_cell_id }" id="{
|
ii_html->add( |<td{ lv_value }>{ <ls_subitem>-label }</td>| ).
|
||||||
lv_cell_id }" value="{ lv_value }"{ lv_readonly }></td>| ).
|
|
||||||
ENDLOOP.
|
ENDLOOP.
|
||||||
ii_html->add( |</tr>| ).
|
ii_html->add( |</tr>| ).
|
||||||
ENDDO.
|
ii_html->add( |</thead>| ).
|
||||||
ii_html->add( |</tbody>| ).
|
|
||||||
|
|
||||||
ii_html->add( |</table>| ).
|
ii_html->add( |<tbody>| ).
|
||||||
|
DO lv_rows TIMES.
|
||||||
|
lv_rows = sy-index.
|
||||||
|
ii_html->add( |<tr>| ).
|
||||||
|
LOOP AT is_field-subitems ASSIGNING <ls_subitem>.
|
||||||
|
lv_cell_id = |{ is_field-name }-{ lv_rows }-{ sy-tabix }|.
|
||||||
|
lv_value = escape( val = io_values->get( lv_cell_id )
|
||||||
|
format = cl_abap_format=>e_html_attr ).
|
||||||
|
CLEAR lv_readonly.
|
||||||
|
IF <ls_subitem>-readonly = abap_true.
|
||||||
|
lv_readonly = | readonly|.
|
||||||
|
ENDIF.
|
||||||
|
ii_html->add( |<td><input type="text" name="{ lv_cell_id }" id="{
|
||||||
|
lv_cell_id }" value="{ lv_value }"{ lv_readonly }></td>| ).
|
||||||
|
ENDLOOP.
|
||||||
|
ii_html->add( |</tr>| ).
|
||||||
|
ENDDO.
|
||||||
|
ii_html->add( |</tbody>| ).
|
||||||
|
|
||||||
|
ii_html->add( |</table>| ).
|
||||||
|
|
||||||
|
ELSE.
|
||||||
|
ii_html->add( |<input type="text" name="{ is_field-name }" id="{
|
||||||
|
is_field-name }" value="Not available" readonly>| ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
" Hidden field with number of rows to simplify getting values from form
|
" Hidden field with number of rows to simplify getting values from form
|
||||||
lv_value = |{ is_field-name }-{ zif_abapgit_html_form=>c_rows }|.
|
lv_value = |{ is_field-name }-{ zif_abapgit_html_form=>c_rows }|.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user