cancel
Showing results for 
Search instead for 
Did you mean: 

TableView - selectedRowKeyTable

StefanRoesch
Active Participant
0 Kudos

Hello again,

i am still fighting with my TableView and got another Problem. In OnInitialization i fill a table for selectedRowKeyTable and the Tableview looks ok, as the specified keyrows are selected. But when i now send the form and want to identify the selected rows in OnInputProcessing I receive wrong results.

OnInputProcessing:

tv ?= CL_HTMLB_MANAGER=>GET_DATA( request = request
                                  name = 'tableView'
                                  id = 'tv_k' ).
table_event = tv->data.
itItems = table_event->GET_ROWS_SELECTED( ).

Wrongs means here:

- Only the first of all preselected items is identified

- The index of this item is 0

- If i have deselected the preselected items i receive all of them as selected (with correct index) and additional the first one a second time (with index 0)

I think it must have to do something with the missing(?) index.

Any ideas on this?

Thank for your help,

Stefan.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

HI Stefan ,

Is your problem solved?

Regards,

Siddhartha

StefanRoesch
Active Participant
0 Kudos

Hello Siddhartha,

actually i am still busy on this topic. Sorry for not keeping you uptodate.

I noticed different behaviour between TableViews with numeric key-columns and TableViews with character-like key-columns.

When having charater key-columns the “table_event->prevselectedRowKeyTable” returns indeed the correct keys, but when I have numeric key-columns the “table_event->prevselectedRowKeyTable” contains all keys of the items I click on - no matter if they have been preselected through the “SelectedRowKeyTable” (so now disabled) or not. So I have to check them back with the “SelectedRowKeyTable” and delete them if necessary.

Is this something you can confirm?

Furthermore I noticed i cannot use "Select All" and "Deselect All" when there have been entries in the “SelectedRowKeyTable” but this is just a minor problem i can live with...

Thanks guys for your help so far,

Stefan.

Former Member
0 Kudos

HI Stefan,

Sorry, was busy in some other work.

I tested the code by creating a table with key field as numeric(NUMC13) and i didn't get any diffrenent behaviour.Are you refreshing the internal tables that you are using to store the values read like PREVSELECTEDROWKEYTABLE after each request ?

Regards,

Siddhartha

StefanRoesch
Active Participant
0 Kudos

Thanks a lot for your answers, but it seems both approaches do only work if I have ServerRoundTrips at each Row Selection, what was basically not my intention as I need to avoid unnessassary loadingtime.

The

table_event->selectedRowKeyTable

would be great, but it does not exist and

table_event->prevSelectedRowKeyTable

returns only the selected lines which havn't been preselected..Maybe I have to mix this up with my original SelectedRowKeyTable...i'll try this...

Former Member
0 Kudos

HI stefan,

If you don;t want server round trips and want values of all the rows selected , try the code as follows :


 <htmlb:tableView id="tab1"
                  table="<%= itab %>"
                 visibleRowCount="8"
                  design="ALTERNATING"
                  footerVisible="TRUE"
                 selectionMode="multiSelect" 
                 keepSelectedRow="true" >
                 
</htmlb:tableView>

<htmlb:button  id = "but1"
               onClick="test" 

This way your server trip will be once only.

to get the values selected ,in onInputProcessing do something like :


  if  event->id = 'but1' and event->event_type = 'click'.
  DATA: tv TYPE REF TO CL_HTMLB_TABLEVIEW.

  tv ?= CL_HTMLB_MANAGER=>GET_DATA(
                  request      = runtime->server->request
                  name         = 'tableView'
                  id           = 'tab1' ).

IF tv IS NOT INITIAL.

 DATA: tv_data TYPE REF TO CL_HTMLB_EVENT_TABLEVIEW.
  tv_data = tv->data.

 call method tv_data->GET_ROWS_SELECTED
      receiving selected_rows = itab2.

 endif.
data : ind type SELECTEDROW,
       row_s type <table name>.

if itab2 is not initial.
    data :rw LIKE LINE OF itab.

    loop at itab2 into ind.
      READ TABLE itab INDEX ind-index into
      rw.
       if rw is not initial.
       row_s = rw.
      append row_s to itab3.
      clear row_s.
      endif.
    endloop.
 endif.
 
 
 endif.

This will read the selected rows and display the values in another tableview.

Hope this Helps,

Regards,

Siddhartha

Former Member
0 Kudos

HI,

If in your layout your tableView is defined with table name as itab , into which you retrive the data in onInitialization ,

then to get the row selected , in onInputProcessing , use the code as follows


data rowselected type string.
DATA: tv TYPE REF TO CL_HTMLB_TABLEVIEW.

  tv ?= CL_HTMLB_MANAGER=>GET_DATA(
                   request      = runtime->server->request
                   name         = 'tableView'
                   id           = 'tab1' ).
IF tv IS NOT INITIAL.

 DATA: tv_data TYPE REF TO CL_HTMLB_EVENT_TABLEVIEW.
  tv_data = tv->data.

  IF tv_data->SelectedRowIndex IS NOT INITIAL.
    FIELD-SYMBOLS: <row> LIKE LINE OF itab.
    READ TABLE itab INDEX tv_data->SelectedRowIndex ASSIGNING
<row>.
rowselected = <row>-field-name.

endif.

 endif.

Hope this helps ,

Regards,

Siddhartha

Former Member
0 Kudos

Hi Stefan,

Try using this

itItems = table_event->selectedRowKeyTable

or

itItems = table_event->prevSelectedRowKeyTable

See example <b>TableViewMultiSelectKey.bsp

</b> in BSP Application SBSPEXT_TABLE.

Hope it helps.

Regards,

Narinder

Message was edited by: Narinder Singh Hartala