cancel
Showing results for 
Search instead for 
Did you mean: 

Radio Buttons in a Table View Iterator

Former Member
0 Kudos

Hi Friends,

I want to render radio buttons in a Table View using iterator such that after every field, there is a radio button. I also want to trigger an event when they are clicked. How can I do this???? Any sample codes for this scenario????

regards,

Rajesh.

Accepted Solutions (1)

Accepted Solutions (1)

athavanraja
Active Contributor
0 Kudos

Welcome to SDN.

Check this weblog.

/people/brian.mckellar/blog/2003/10/31/bsp-programming-htmlb-tableview-iterator

/people/thomas.jung3/blog/2004/09/15/bsp-150-a-developer146s-journal-part-xi--table-view-iterators

Regards

Raja

Former Member
0 Kudos

Hi ,

The links were useful. But it didnt solve my problem. I am using factory method for rendering the radio button. But I am getting a blank instead of the button. I also want to display the values in the cells on a single row outside the tableview when the button is clicked. How can thhis be achieved?

Here is the code that i have used for rendering the radio button in the iterator.

CASE p_column_key.

when 'select'.

p_replacement_bee = cl_htmlb_radiobutton=>factory(

id = p_cell_id

key = 'Y').

Did i miss something here??? I tried giving the attributes 'checked', 'onClick', but just couldnt get it going.

regards,

Rajesh.

Former Member
0 Kudos

try initiating the TEXT value

athavanraja
Active Contributor
0 Kudos

how do you want the radio buttons to be grouped (without grouping them radiobuttons doesnt make sense)

if you want to group it on rows. (thats only one radiobutton in a column can be selected for all rows.)

suppose you have 10 rows and column 2 is radiobutton and you want the user to be able to select only one row then you cannot use p_cell_id the id of radiobutton.

so the point here is you have to careful when defining the id parameter of the radiobutton.

why you are seeing blank.

because of the when statement.

CASE p_column_key.

when 'select'.

it should be

CASE p_column_key.

<b>when 'SELECT'.</b>

these kind of issues you can figure it out by debugging.

i have defined radiobuttons in my tableview like below.

(iterator code)

WHEN 'RAD1' .

DATA: rad_gp TYPE REF TO cl_bsp_bee_table.

CREATE OBJECT rad_gp.

rad_gp->add_html( html = '<input type="radio" value="V1" checked name="R1">' ).

p_replacement_bee = rad_gp.

Regards

Raja

Former Member
0 Kudos

Hi Raja,

What you had said is correct. I want to group the buttons on rows. i.e only one button can be selected from a column, however all radio buttons in a row can be selected. And when i click on a button, i should be able to display the contents in the cell in a selerate row which is outside this table view.

For example:

Partner Select ID Number Select Street Select Initials

000001 X 100189 56 T

000002 100189 X 56 M

000003 100189 56 X S

The 'select' columns are where i intend to have my Radio Buttons. The user can select only one Radio Button per column but all columns in a Row can be selected. When selection in all columns are made(it will become one record). Now I want to display the details based on the selections as shown below:

Partner Select ID Number Select Street Select Initials

100189 56 S

This has to be displayed instantly. That is, when the user clicks on one radio button, that value should immediately be displayed in a row which is above the TableView.

I have used the following code to get my radio buttons displayed in the table view.

WHEN 'SELECT' .

DATA: rad_gp1 TYPE REF TO cl_bsp_bee_table.

CREATE OBJECT rad_gp1.

rad_gp1->add_html(

html = '<input type="radio" value="V1" checked name="R1" >'

).

p_replacement_bee = rad_gp1.

What modification i have to make in this to capture the onClick event????

regards,

Rajesh.

athavanraja
Active Contributor
0 Kudos

just after htmlb:form enter the following code.

<%@extension name="bsp" prefix="bsp" %>

<bsp:htmlbEvent id = "RBCLICK"

onClick = "myonclick"

name = "ValueChanged"/>

now inthe iterator

WHEN 'SELECT1' .

DATA: rad_gp TYPE REF TO cl_bsp_bee_table.

CREATE OBJECT rad_gp.

rad_gp->add_html( html = '<input type="radio" value="V1" checked name="R1" onclick="valuechanged();">' ).

p_replacement_bee = rad_gp.

WHEN 'SELECT2' .

DATA: rad_gp1 TYPE REF TO cl_bsp_bee_table.

CREATE OBJECT rad_gp1.

rad_gp1->add_html( html = '<input type="radio" name="R1" value="V2" onclick="valuechanged();">' ).

p_replacement_bee = rad_gp1.

This would , when the user clicks a radiobutton, trigger server event where you can collect further info and present in the layout.

Hope this is clear.

Regards

Raja

Former Member
0 Kudos

Hi Raja,

I have done the modifications suggested by you. But I am facing problems while capturing the event.

DATA: event TYPE REF TO cl_htmlb_event.

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

IF event->name = 'button' AND event->event_type = 'click'.

.....

ENDIF.

I am getting the event as initial and which results in a dump because of NULL reference. ( OBJECTS_OBJREF_NOT_ASSIGNED ). I have other buttons on the page and am getting the events for them. But when i click on the radio button, the event is not being captured. Any idea where i went wrong??

thanks & regards,

Rajesh.

athavanraja
Active Contributor
0 Kudos

try this oninputprocessing.

DATA eventex TYPE REF TO if_htmlb_data.

eventex = cl_htmlb_manager=>get_event_ex( request ).

if eventex->EVENT_ID = 'RBCLICK' .

  • radiobutton is clicked

endif .

Regards

Raja

Former Member
0 Kudos

Hi,

I was able to capture the event using eventex = cl_htmlb_manager=>get_event_ex( request ).

I have another requirement where i want to highlight the cell that has been clicked(i am not using Iterator this time). How can i do that??? For example i have a column 'Customer No:' and there are 10 rows in my Table View. Suppose I click on a 'Customer No:' cell in the 3rd row, that particular cell should be highlited in say Blue colour.

regards,

Rajesh.

athavanraja
Active Contributor
0 Kudos

is it a editable column or non editable?

Regards

Raja

Former Member
0 Kudos

Hi,

I have set the property of the tableViewColumn as

<htmlb:tableViewColumn edit = "TRUE"

onCellClick = "onCellClick_partner">

Using this onCellClick property, i am displaying the contents of the cell in a single line outside the tableview such that when we click on a cell, its value appears above the tableview. But I want to identify the cell in which i clicked. Something like changing the colour of the cell that has been clicked. I am not using an iteraror.

regards,

Rajesh.

athavanraja
Active Contributor
0 Kudos

write the following code after </htmlb:table> tag

<script for="IP1" event=onclick type="text/javascript">

document.myform.IP1.select();

</script>

replace IP1 with your cell id. cell id pattern will be

<tableviewID>_<rownumber>_<columnnumber>

Regards

Raja

Answers (0)