cancel
Showing results for 
Search instead for 
Did you mean: 

Radio Button / check box

Former Member
0 Kudos

Hi all,

Could Any one help me out in working with Radio buttons and Check boxes by sending any useful material.

1)Currently my requirement is if I click on a radio button in the table, corresponding row have to go as input to other bapi.

2) If I check the check boxes (one or more) in the table, only corresponding row( which are checked) should be captured and displayed in the next screen.

regards

Deepu

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

1)create 1 attribute as select,bind this attribute to checkbox

2)insert checkbox in table

3)click checkbox->properties>onToggle->create action and write the code

Declare flag as global variable,

static int flag;

{

flag=wdContext.nodeViewFlightTest().getLeadSelection();

}

4)In table properties there is an option,onLeadSelection---->create action

it is used to select only 1 check box, defaultly first record is in lead selection, u want to select some other record...u have uncheck first checkbox....for that we using this code....

if(wdContext.nodeViewFlightTest().getViewFlightTestElementAt(flag).getSelect())

{

wdContext.nodeViewFlightTest().getViewFlightTestElementAt(flag).setSelect(false);

}

5)context map ur first view Bapi node to component controller then context map second view to component controller....

6)using apply template in second view,u can display whatever data u want....

Former Member
0 Kudos

Hi Suresh,

what if i want to select more than one row at a time and display all the checked rows at a time in other table?

Former Member
0 Kudos

Hai,

-node

-some value

-some value

-some value

-boolean value

bind this to table table automatically create check box for boolean attribute.

for(int i=0;i<nodesize;i++){

if(wdContext.nodeXX().getXXElementAt(i).getboolean){

do the code necessary for selected row

}

Regards,

Naga

}

Former Member
0 Kudos

Hi suresh,

Could you please help me in radio buttons. I have table with unknown rows, I need a radio button for each row, and at a time only one row could be selected. and I need to get the values of corresponding row.

plz help me out

Former Member
0 Kudos

Hi,

Since you have mapped a single boolean value to all the radiobuttons in the table, what happens is when ever that boolean value is set to true all the radiobuttons get selected, since the boolean is set to true.

Former Member
0 Kudos

Hi,

Go through the thread for you solution for radibutton

One more for more insight

getting the values of the selected row when a user clicks a radiobutton is as good as getting the leadselection of the table.

In the action of radiobutton

int i = wdContext.nodeTable.getLeadSelection(); // get the row selected.

wdContext.nodeTable.getTableElementAt(i).get<tableColumnName>(); // get the elements of the selected row.

Store this value or set it directly to the Bapi input attributes and then call the execute method of the BAPI.

Message was edited by:

Shriram Kabra

Former Member
0 Kudos

If I check the check boxes (one or more) in the table, only corresponding row( which are checked) should be captured and displayed in the next screen.

View which had table with checkbox "MainView"

View where checkbox selected row to be displayed "DisplayView"

Cardinality of the tablenode in both the view is 0..n with selection mode 0..1

Also see that the DisplayView node for table is avialble in the Main view through

proper context mapping.

Assuming your Table node is like this in both the views

Context

--Table (node)

-


Name (attribute)

-


UserID (arribute)

Inside the Main view

1. Create a column under the table.

2. Right click on the columns and select Insert TableCellEditor and choose CheckBox

3. Create a value attribute "Checked" of type boolean under the table node.

4. In your action to navigate to other view

// fire a outbound plug to the next screen

5. In the inBound lug method of the DisplayView

for(int i=0;i<wdContext.node<MainViewTableNode>().size();i++)

{

if(wdContext.node<MainViewTableNode>().get<MainViewTableNode>ElementAt(i).getChecked())

{

// create element in the node of Display View

IPrivateDisplayView.I<DisplayViewNode>Element elem = wdContext.node<DsiplayView>().createCElement();

wdContext.node<DsiplayView>().addElement(elem);

// add the selected row values to the node of DisplayView elem.setName(wdContext.nodeMainViewTableNode().getMainViewTableNodeElementAt(i).getName());

elem.setUserID(wdContext.nodeMainViewTableNode().getMainViewTableNodeElementAt(i).getUserID());

}

}

Former Member
0 Kudos

HI,

1) When I am selecting one check box, all other checkboxes (including selected one) are activating (selecting automatically), when I uncheck one check box all others are disabled (including selected one). what I need to do.

2) And you said that to write the code in inBound plug. I am writing it in ontoggle method. and by default fist row is going to next screen.

Please help me out in this regard.......

(I need to select multiple checkboxes in the table)

Former Member
0 Kudos

Hi,

Give me your mail ID. I will send you a sample application.

Former Member
0 Kudos

pradeep_bondla@satyam.com

and also I have followin problems

I am using check box in my table. and writing the code in "ontoggle" method of the check box.

1) when I am selecting a checkbox in the 3 rd row of the table, in the next screen (where it should display in the first row ) its leaving first 2 rows empty and showing in the 3 rd row. same if i select 5 th row, its showing all 4 rows empty and showing in the 5th row. How to show rows from 1st row.... ( I am selecting multiple rows)

2) when I am selecting one row, after navigating to next screen if I go back and select another row, first displayed row is not refreshing. old values exist in the displayed table. how to refresh it.

3)If I select a check box and unselect it immediatly, still that row is displaying in the next screen. what to do if I want NOT to display if a check box selected and unselected without proceeding to next screen...

4) in the second screen when i click back button, I could see the selected check boxes checked only, what to do to refresh the page when I come back and go front

Former Member
0 Kudos

Hi Pradep,

I think you will be using 'lead selection' to display the records in next screen, then only one row, which is been lead selected will be displayed in second screen. Use the check box '

state

' for displaying the selected records in next screen.(i.e) Display the records whose checkbox state is '

true

'.

Regards,

Prabhakar.

Former Member
0 Kudos

yes u r right..... Now I almost got it.... just one problem...

in main screen after the records one empty checkbox with row and in the display view first row with empty fields and check box comming. actually in the display view the records should be displayed in from 1st row of the table but its populating from 2nd row.... what would be the problem???

Former Member
0 Kudos

Hi,

Try by setting the selection property of the table to 0..1.

Regards,

Prabhakar

Former Member
0 Kudos

it is already cardinality is 1..n and selection is 0..1. but facing that problem.

Former Member
0 Kudos

Hi,

sent you the application.

Need anything more will let you know.

Former Member
0 Kudos

hi,

Since the cardinality of the table node is 1..n,

webdynpro runtime creates a element for that node by default.

change the cardinality to 0..n, since in your code you are creating the

elements of the table in the DisplayView.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Pradeep,

In the 'Layout', to the Table UIElement, add a column and insert a Table Cell Editor of type Radio Button. Now, in the 'Context', within the node bound to the table, insert a value attribute key_to_sel of type string. Also create a value attribute sel_key of type boolean directly under the root node (context itself). Now, map the keyToSelect property of the radiobutton to ' key_to_sel ' and selectedKey property to ' sel_key '. This will see to it that you are able to select only one radiobutton at a time.

Kindly revert back for more details.

Regards,

Leena

Former Member
0 Kudos
Former Member
0 Kudos

Hi Pradeep,

1)Currently my requirement is if I click on a radio button in the table, corresponding row have to go as input to other bapi.

There is an event in the radio button which gets called every time the radiobutton is selected and vice-versa you have to get the lead selected element of the table node and add it to the BAPI from there.

2) If I check the check boxes (one or more) in the table, only corresponding row( which are checked) should be captured and displayed in the next screen.

Again the event for check box is onToggle which will and similarly get the leadselected element in the table node and buffer it some other node use WDValueServices for copying it to the exact same node structure as that of the table datasource and then you can display it once you map this node to another view.

Regards

Amit

Former Member
0 Kudos

Thank you,

What should I map for "keyToSelect" and "selectedKey" of the radio button properties. one thing we can map is radio buttons boolean type value attribute, that too for which one to map.

Former Member
0 Kudos

Hai pradeep,

for Radiobuttons,

context look like

-node

-somevalue

-somevalue

-somevalue

-keytoSelect

-selected key.

bind this node to your table, just bind the keyselect and selcted key to your radiobutton.

evry radio button in a row is having a unique keytoselectvalue, If you select any of the radiobutton, the keytoselect value is to be the selcted key like this,

mostly you can use id of the row be the keytoselect for radio button.

Regards,

Naga

Former Member
0 Kudos

In this case check out the following code :

keyToSelect: Specifies the value of the key that is used to select the radio Button

type String.

selected key:This is mandatory property which store the selected value which is Mandatory.

Regards

Amit

Former Member
0 Kudos

In the output I could see all the radio buttons are ticked (selected), I want only one radio button to be Selected at a time, how to check only one radio button at a time?

and also give me sample code to get the values of corresponding table row for which radio button is selected.

Former Member
0 Kudos

You will have to set the property selectedkey to false in that case.

Code sample for sample code to get the values of corresponding table row for which radio button is selected:

when it goes to the selectEvent create a boolean attribute and set a condition to access the wdDoModifyView()


 IWDTable table = (IWDTable)view.getElement("tableName");
	IPrivateView1.INode1Node node1 = wdContext.nodeNode1();
    for(int i=0;i<node1.size();i++){
       
       boolean b = node1.getNode1ElementAt(i).getSelectedKey();
       // pass this node element to the BAPI by 
//for the property value true.
    }

Regards

Amit

Message was edited by:

Amit Kesari

Former Member
0 Kudos

In the doInit() of the table view I made the radio button false, but still it i am seeing all radio buttons are selected. I am not able to select only one radio button.

I wrote

wdcontext.currentContextElement.setVaRadioButton(false);

in doInit() of the table view.

what I need to do??

2) which node i need to pass?? like

if(b)

{

// then get the single row?? (how??)

}

please help me out

Former Member
0 Kudos

Hi Amit,

I am not getting getSelectedKey() method.

Former Member
0 Kudos

Hi Pradeep..

see thse links..

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/edf6ea90-0201-0010-7696-a68...

This is the link with example for checkbox group and radio button..

http://help.sap.com/saphelp_erp2005/helpdata/en/95/93fe1e71a2e44691b1f041e67f71aa/content.htm

This thread contains the details abt radio button and check box. It might be useful

for you.

URs GS