cancel
Showing results for 
Search instead for 
Did you mean: 

Table view help required

Former Member
0 Kudos

hi,

I've a htmlb tableview which gets the data from an internal table which is a data member of a model. I've two column fields in this view which are editable. What are the steps I need to follow in order to get the internal table updated with the values provided by the user in the editable fields of tableview.

could someone please provide me with the steps as to how to achieve this?

Thanks and Regards,

Vamshi

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Vamshi,

Try this sample code,as it helps you considerably.

local types

*----


types: itabtype type TABLE OF STD1.

types: begin of message_struct,

type type char10,

text type char100,

end of message_struct.

*----


  • page attributes

*----


addtab TYPE ITABTYPE

addtab_row TYPE STD1

add_flag TYPE FLAG

deltab TYPE ITABTYE

deltab_row TYPE STD1

ITAB TYPE ITABTYPE

iterator TYPE REF TO IF_HTMLB_TABLEVIEW_ITERATOR

message TYPE MESSAGE_STRUCT

STUDENT TYPE STRING

STATUS TYPE STRING

<b>layout</b>

<htmlb:content design="design2003" >

<htmlb:page title="test1" >

<htmlb:form>

<htmlb:tableView id = "tv1"

visibleRowCount = "20"

onRowSelection = "MyEventRowSelection"

selectionMode = "lineEdit"

table = "<%= ITAB %>"

iterator = "<%=iterator %>" />

<htmlb:button id = "save"

text = "Save Changes"

onClick = "myEvent" />

*----


  • eventhandler OnCreate

*----


  • this handler is called once the page is first created (stateful mode)

  • it performs a once-off data initialization or object creation

SELECT * FROM STD1

INTO CORRESPONDING FIELDS OF TABLE itab.

CREATE OBJECT iterator TYPE STD1ITERATOR.

*----


  • eventhandler OnInputProcessing

*----


  • event handler for checking and processing user input and

  • for defining navigation

DATA: ITAB_WA type Line of itabtype.

DATA: event TYPE REF TO cl_htmlb_event.

event = cl_htmlb_manager=>get_event( runtime->server->request ).

FIELD-SYMBOLS: <row> type STD1.

DATA: tv TYPE REF TO cl_htmlb_tableview.

tv ?= cl_htmlb_manager=>get_data(

request = runtime->server->request

name = 'tableView'

id = 'tv1' ).

IF tv IS NOT INITIAL.

DATA: tv_data TYPE REF TO cl_htmlb_event_tableview.

tv_data = tv->data.

IF tv_data->prevselectedrowindex IS NOT INITIAL.

  • FIELD-SYMBOLS: <row> type LINE OF ITABTYPE .

READ TABLE ITAB INDEX tv_data->prevselectedrowindex

ASSIGNING <row>.

DATA value TYPE string.

if <row> is assigned.

value = tv_data->get_cell_id( row_index =

tv_data->prevselectedrowindex

column_index = '1' ).

DATA: inputfield TYPE REF TO cl_htmlb_inputfield.

inputfield ?= cl_htmlb_manager=>get_data(

request = request

name = 'inputfield'

id = value ).

<row>-STUDENT = inputfield->value.

value = tv_data->get_cell_id( row_index =

tv_data->prevselectedrowindex

column_index = '2' ).

inputfield ?= cl_htmlb_manager=>get_data(

request = request

name = 'inputfield'

id = value ).

<row>-STATUS = inputfield->value.

ENDIF.

ENDIF.

WHEN 'add'.

tv ?= cl_htmlb_manager=>get_data(

request = runtime->server->request

name = 'tableView'

id = 'tv1' ).

IF tv IS NOT INITIAL.

tv_data = tv->data.

IF tv_data->prevselectedrowindex IS NOT INITIAL.

READ TABLE itab INDEX tv_data->prevselectedrowindex

ASSIGNING <row>.

endif.

endif.

WHEN 'add'.

add_flag = 'Y'.

WHEN 'add_save'.

ITAB_WA-STATUS = request->get_form_field( 'STUDENT' ).

ITAB_WA-STATUS = request->get_form_field( 'STATUS' ).

endcase.

Former Member
0 Kudos

write the path in the layout of the page view as "//<model class object>/<internal table>"

for example:

<htmlb:tableView id = "matdesctab"

design = "ALTERNATING"

table = "//model/I_MATMAST"

selectionMode = "LINEEDIT"

onRowSelection = "edit" >

This will take the current values in the internal table & write the code to save them on clicking the SAVE button.

Regards,

Hemant.

athavanraja
Active Contributor
0 Kudos

oninput processing write code to retrive the values and update your table or use data binding.

for both the methods, search this forum, there are lot of example code.

Regards

Raja