cancel
Showing results for 
Search instead for 
Did you mean: 

Input field in an iterator

former_member194147
Participant
0 Kudos

Guys I m using an Iterator and in its method.

method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START.

I m coding like this to have an input field in a tableview

p_replacement_bee = CL_HTMLB_INPUTFIELD=>FACTORY( id = p_cell_id

id_postfix = '_input'

type = 'STRING'

value = CURRENT_STATE ).

I m getting an input field in the tableview but my roblem is this that when a user enters data into any cell of the inputfield in the tableview, I need to read that row.

I m using flow logic and I am unable to catch that newly enter data.

Kindly help.

Dhananjay

Accepted Solutions (1)

Accepted Solutions (1)

former_member194147
Participant
0 Kudos

I am still not able to get newly enterd data.

I have used all the 3 methods mentioned by u.

Kindly help.

Dhananjay

athavanraja
Active Contributor
0 Kudos

post

htmlb:tableview code in layout

interator code where you created inputfield for cell

and

your oninputprocessing code.

Regards

Raja

former_member194147
Participant
0 Kudos

layout code

<htmlb:tableView id = "tvX"

headerText = "Communication"

headerVisible = "true"

design = "alternating"

visibleRowCount = "4"

fillUpEmptyRows = "true"

onHeaderClick = "MyEventHeaderClick"

onRowSelection = "MyEventRowSelection"

selectionMode = "LINEEDIT"

table = "<%= itab %>"

iterator = "<%= iterator %>" >

</htmlb:tableView>

Oninputprocessing code

event = CL_HTMLB_MANAGER=>get_event_ex( runtime->server->request ).

event_id1 = cl_htmlb_manager=>event_id.

CASE event->event_name.

WHEN 'inputField'.

DATA : w_newvalue TYPE string,

w_row TYPE sytabix,

w_col TYPE sytabix.

w_col = '1'.

FIELD-SYMBOLS: <line> TYPE ANY,

<field> TYPE ANY.

READ TABLE itab INDEX ind ASSIGNING <line>.

ASSIGN COMPONENT w_col OF STRUCTURE <line> TO <field>.

IF sy-subrc = 0.

<field> = w_newvalue.

ENDIF.

var = request->get_form_field( name = 'tvX_1_1' ).

ENDCASE.

Iterator code

method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START.

CASE p_column_key.

WHEN 'CURRENT_STATE'.

DATA: if_input TYPE REF TO CL_HTMLB_INPUTFIELD,

if_text TYPE REF TO CL_HTMLB_TEXTVIEW.

CURRENT_STATE = m_row_ref->CURRENT_STATE.

p_replacement_bee = CL_HTMLB_INPUTFIELD=>FACTORY( id = p_cell_id

id_postfix = '_input'

type = 'STRING'

submitOnEnter = 'TRUE'

value = CURRENT_STATE ).

athavanraja
Active Contributor
0 Kudos

since you have used id_postfix change the following code

var = request->get_form_field( name = 'tvX_1_1<b>_postfix'</b> ).

Regards

Raja

Answers (1)

Answers (1)

guillaume-hrc
Active Contributor
0 Kudos

Hi Dhananjay,

To achieve this, you have to provide a submitOnEnter somewhere, or use JavaScript with the onChange event

Best regards,

Guillaume

Message was edited by: Guillaume Garcia

former_member194147
Participant
0 Kudos

Hi Garcia,

The class CL_HTMLB_INPUTFIELD doesnt have this parameter onclick.

So I guess we cant use onclick here.

guillaume-hrc
Active Contributor
0 Kudos

Yes, you are right !

I got mixed up a bit... my apologies.

Like corrected above, I think you should try the <b>submitOnEnter</b> attribute of inputFields.

Have a look at this thread for possible solution :

Best regards,

Guillaume

Message was edited by: Guillaume Garcia

former_member194147
Participant
0 Kudos

Hi Garcia

How can I implement submitOnEnter in a tableView iterator.

Can you elaborate this.

Thanx

guillaume-hrc
Active Contributor
0 Kudos

Another approach is to use htmlbEvent to register JavaScript event. This way, it will trigger a server event.

Well, as I am not very familiar with this, let the master talks...

/people/brian.mckellar/blog/2004/07/18/bsp-in-depth-using-the-htmlb-event-system

Best regards,

Guillaume

athavanraja
Active Contributor
0 Kudos

<i>when a user enters data into any cell of the inputfield in the tableview, I need to read that row.</i>

can you elobarate on this.

as soon as user enters value and moves to another field, you want to read the value?

this means this would involve lot of server round trip which will reduce the performance of your page.

why cant you reall all of them at the end by user clicking a button at the end called something like "finished enterting store it".

to capture each field change as Guillaume suggested you need to do it thru javascript which will trigger a server roundtrip.

(search the forum for key wor "<bsp:htmlbEvent" i haveposted some sample code earlier)

Regards

Raja

guillaume-hrc
Active Contributor
0 Kudos

Hi,

Did you managed to find a solution ?

You do not implement submitOnEnter in a tableView iterator, but on each inputField your Iterator is creating.

=> thus, you only have to set the parameter'submitOnEnter' to true in the factory method you gave in your initial post.

For further information, refer to the link I provided.

Best regards,

Guillaume

former_member194147
Participant
0 Kudos

Hi Raja

What I want is when the user enters any value in the cell,

and press any button or hit enter , that value should be change in the internal table, so that the change value is visible in the tableView.

Kindly also provide code snippet for it.

I hope for this Javascript is not needed.

Kindly reply

athavanraja
Active Contributor
0 Kudos

<i>that value should be change in the internal table, so that the change value is visible in the tableView.</i>

to do this you have have to update the itab (when there is no server round trip.

but if you still want to capture each cell change.

after htmlb:tableview tag have the following javascripts

<bsp:htmlbEvent id = "myid"

onClick = "myonclick"

name = "ValueChanged" />

<script for="tv1_1_5" event=onchange type="text/javascript">

ValueChanged();

</script>

this would trigger oninputprocessing when the value changes in 1st row 5th column. where you can read the field value to update in your itab.

Regards

Raja

Request: Guillaume Garcia is also actively participating in this thread and giving valuable suggestions, and by directly addressing me , you may sound ignoring him and be hurting Guillaume Garcia and i feel this can be avoided. Hope this request is taken in the right sprit.

guillaume-hrc
Active Contributor
0 Kudos

Hi,

In the iterator:

p_replacement_bee = cl_htmlb_inputfield=>factory( 
id        = p_cell_id
type      = 'STRING'
value     = w_str_cell
submitOnEnter = 'true'
cellvalue = 'true' ).

In the associated OnInputProcessing event handler of the page containing your tableView:

DATA: event  TYPE REF TO if_htmlb_data.

event = cl_htmlb_manager=>get_event_ex( request ).

* Test that this is an event from HTMLB library.
CHECK event IS NOT INITIAL.
CHECK event_id = cl_htmlb_manager=>event_id.

*------------------
* Event Handling
*------------------
CASE event->event_name.

  WHEN 'inputField'.
    DATA : w_newvalue   TYPE string,
           w_row        TYPE sytabix,
           w_col        TYPE sytabix.
    
    FIELD-SYMBOLS: <line>   TYPE ANY,
                   <field>  TYPE ANY.
           
    w_newvalue = request->get_form_field( event->event_id ).
*   Now, determine row and column depending on your iterator!
*   For this, use event->event_id that follows this formatting rule :
*     <tableview_id>_row_column
*
*   Let's say : 
*     - w_row  holds the row of the inputField
*     - w_col  holds the column of the inputField

    READ TABLE tab INDEX w_row ASSIGNING <line>.
    ASSIGN COMPONENT w_col OF STRUCTURE <line> INTO <field>.
    IF sy-subrc = 0.
      <field> = new_value.
    ENDIF.

ENDCASE.

There is still a bit of work to be done here to adapt the solution to the iterator. This definitely has to be tested.

Best regards,

Guillaume

Request's response : thanks for your kindness, Raja !

Message was edited by: Guillaume Garcia

former_member194147
Participant
0 Kudos

Hi,

Well I held both of u in high regards, but when I want to clarify a particular solution ,I have to take the name of the solution provider.

Plz dont take otherwise.

Now Garcia the sol'n that u have provided is working but I have 1 problem. The problem is this that in my OnInputprocessing.

I have coded like this

DATA: EVENT1 TYPE REF TO CL_HTMLB_EVENT.

data: event2 type string.

CLASS CL_HTMLB_MANAGER DEFINITION LOAD.

EVENT1 = CL_HTMLB_MANAGER=>GET_EVENT( RUNTIME->SERVER->REQUEST ).

event2 = EVENT1->IF_HTMLB_DATA~EVENT_ID.

Now in event2 I m getting the id of the respective htmlb objects like button id.

Now if I implement ur code ,I am able to catch the event but when the cursor comes on the above code it gives error stating referenced object referred to null.

Kindly reply

Dhananjay

athavanraja
Active Contributor
0 Kudos

Thanks for clarification and i understand your point.

to over come that

EVENT1 = CL_HTMLB_MANAGER=>GET_EVENT( RUNTIME->SERVER->REQUEST ).

if not event1 is initial . " if its initial its not a htmlb event.

event2 = EVENT1->IF_HTMLB_DATA~EVENT_ID.

endif .

Regards

Raja

Message was edited by: Durairaj Athavan Raja

former_member194147
Participant
0 Kudos

Thanx Raja,

But I still have that problem.

Using above Garcia's code I am able to catch that event in my oninputprocessing but still I am unable to retrieve that new value which the user enters in to the cell.

How to retreive this newly entered data ?

Kindly reply.

Dhanajay

athavanraja
Active Contributor
0 Kudos

so what you are saying is that, triggering the oninputprocessing when the values changes inthe cell is solved and the problem now is how to read the cell value in oninputprocessing.


option1 .

 data: data type ref to cl_htmlb_inputfield.
  data ?= cl_htmlb_manager=>get_data( request      = runtime->server->request
                                      name         = 'inputField'
                                      id           = 'TV1_1_5' " here TV1 is the tableview id 1- 1st row 5 - 5th column
                                    ).
  if data is not initial.
    cell_value = data->value.
  endif.

options 2 .

cell_value = request->get_form_field( name = 'TV1_1_5' ) .

option 3 .

request->get_form_fields , this will return all form fields in the layout as a name value pair in a internal table which you can read to get the data.

Hope this is clear.

Regards

Raja