08-03-2021 2:35 PM
METHOD set_columns.
DATA columns TYPE REF TO cl_salv_columns_tree.
columns = tree->get_columns( ).
columns->set_optimize( ).
DATA all_columns TYPE salv_t_column_ref.
all_columns = columns->get( ).
DATA column TYPE salv_s_column_ref.
LOOP AT all_columns INTO column.
CASE column-columnname.
WHEN 'GROUP_NAME'.
column-r_column->set_output_length( 30 ).
WHEN 'OWNER'.
column-r_column->set_technical( ).
WHEN 'DESCRIPT'.
column-r_column->set_output_length( 30 ).
WHEN 'CLASS_NAME'.
column-r_column->set_technical( ).
WHEN 'ACTIVE'.
column-r_column->set_output_length( 10 ).
ENDCASE.
ENDLOOP.
ENDMETHOD.
The set_output_length methods calls have no effect. The column width is set to the width of the column header. The tree is visible.
When I take out set_optimize the column widths are as I want them - but the tree isn't visible.
Any ideas?
08-03-2021 4:51 PM
Weird.
Maybe you can get better results with this:
tree->get_tree_settings( )->set_hierarchy_size( 50 ). " width you want
08-03-2021 4:51 PM
Weird.
Maybe you can get better results with this:
tree->get_tree_settings( )->set_hierarchy_size( 50 ). " width you want
08-03-2021 6:07 PM
I'm glad you think it's weird. I was beginning to doubt myself. It's the first time I've used CL_SALV_TREE, believe it or not. The column width is my only remaining issue.
I'll try the tree settings thing tomorrow.
08-04-2021 8:18 AM
Yes. It works!
Once again your technical brilliance shines through. Thank you.
08-04-2021 8:43 AM
frdric.girod matthew.billingham When I have a doubt, I test before answering (what I did yesterday), here was my "minimal reproducible example" (play with <========= to see a weird result when combining):
DATA: go_tree TYPE REF TO cl_salv_tree,
gt_outtab TYPE TABLE OF alv_t_t2.
TRY.
" Note: T_TABLE must be empty otherwise exception occurs immediately!
" ADD_NODE fills the T_TABLE, SET_DATA_ROW updates it
gt_outtab = VALUE #( ).
cl_salv_tree=>factory(
IMPORTING
r_salv_tree = go_tree
CHANGING
t_table = gt_outtab ).
go_tree->get_columns( )->set_optimize( ). " <=====================
* go_tree->get_columns( )->get_column( 'FLDATE' )->set_optimized( ). " <=====================
* go_tree->get_tree_settings( )->set_hierarchy_size( 50 ). " <=====================
DATA(nodes) = go_tree->get_nodes( ).
DATA(node_key) = nodes->add_node( related_node = ''
text = 'root'
relationship = cl_gui_column_tree=>relat_last_child
)->get_key( ).
SELECT * FROM alv_t_t2 INTO TABLE @DATA(lt_outtab) UP TO 3 ROWS.
LOOP AT lt_outtab REFERENCE INTO DATA(alv_line).
node_key = nodes->add_node( related_node = node_key
data_row = alv_line->*
text = |{ alv_line->carrid }|
relationship = cl_gui_column_tree=>relat_last_child
)->get_key( ).
ENDLOOP.
go_tree->display( ).
CATCH cx_salv_error INTO DATA(lx).
MESSAGE lx TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
08-04-2021 6:55 AM
it it is possible, can you isolate this tree an provide the code, we could check in our system too.
08-04-2021 8:15 AM
08-04-2021 9:26 AM