cancel
Showing results for 
Search instead for 
Did you mean: 

Confused with KeyToSelect and SelectedKey of the Table

Former Member
0 Kudos

Hi,

Can anyone explain with simple example (If possible), what is the use of KeyToSelect and SelectedKey properties of the table and difference between two. I read it in help document and got confused.

Thanks in Advance,

Saravanan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Saravanan,

Table doesn't have properties called 'keyToSelect' and 'SelectedKey'. If you are talking about the same properties of RadioButton:

Radiobutton is usually used in groups. So the 'KeyToSelect' property says the unique value to identify each radio button, while 'SelectedKey' says which attribute has the value of the currently selected radio button. So if we need to group few radio buttons together, each of the radiobutton will have a unique value for 'KeyToSelect' but the 'SelectedKey' would be bound to the same attribute. Anytime, we access the value of the attribute bound to 'SelectedKey', we will get the 'keyToSelect' value of the currently selected radiobutton.

Hope this helps,

Best Regards,

Nibu.

Answers (6)

Answers (6)

Former Member
0 Kudos

HI Saravanan,

For every radio button there will be key to select and selected key.

for this u have to create 2 attributes in the context as R1 and sel(where sel is common for both R1 and R2 buttons)

where we have to bind keytoselect with R1 and

selectedkey with sel.

for suppose there 2 radio buttons true and false buttons. By default one should be enabled ,either true or false button.Inorder to make it default enable,selectedkey should bind with sel.

here is the small example with code:

Assume that u r having 2 Radio buttons R1 and R2.

For this u create 3 attributes R1,R2 and Sel.

For the radio button R1:

set the element properties as:

keytoselect---R1

selected key --Sel

For the radio button R2:

set the element properties as:

keytoselect---R2

selected key --Sel

In implementation part :

public void wdDoInit()

{

//@@begin wdDoInit()

wdContext.currentContextElement().setR1("Pass");

wdContext.currentContextElement().setR2("Fail");

wdContext.currentContextElement().setSel("Pass");

//@@end

}

SO from the above code the default radio button R1 will be enabled.

If u want the second radio button to be default then change sel to

wdContext.currentContextElement().setSel("Fail");

so during run time when u select the first one automatically its selvalue changes according to the radio button's value.

*******Points please

Regards,

Krishnam Raju.

Former Member
0 Kudos

HI ,

here is the example for ur question.

keytoselect should bind with the radion button and

selected key should bind with the key which should be selected(enabled) by default.

Please follow the below example.From this it will be clear.

Assume that u r having 2 Radio buttons R1 and R2.

For this u create 3 attributes R1,R2 and Sel.

For the radio button R1:

set the element properties as:

keytoselect---R1

selected key --Sel

For the radio button R2:

set the element properties as:

keytoselect---R2

selected key --Sel

In implementation part :

public void wdDoInit()

{

//@@begin wdDoInit()

wdContext.currentContextElement().setR1("Pass");

wdContext.currentContextElement().setR2("Fail");

wdContext.currentContextElement().setSel("Pass");

//@@end

}

SO from the above code the default radio button R1 will be enabled.

If u want the second radio button to be default then change sel to

wdContext.currentContextElement().setSel("Fail");

so during run time when u select the first one automatically its selvalue changes according to the radio button's value.

  • Points please..............*

Regards,

Krishnam Raju.

Former Member
0 Kudos

It's the data binding model for radio buttons.

All radio button's "selectedKey" properties are bound to a common context attribute K.

Each radio button get's a <b>key to select</b> it. This is done by setting the "keyToSelect" property of each radio button to a distinct value.

Now if K contains the "keyToSelect" of radio button B, then B appears selected.

Armin

Former Member
0 Kudos

Hi All,

Thanks for the Your Response. What i really meant is Radio Button in table cell editor of Table. I saw one example of table display in WD Application.

I got the answers.

Points are on the way for u guys ..

Thanks

Saravanan

Former Member
0 Kudos

RB1 - key2select1 - mapped to attr1 - val1

RB2 - key2select 2 - mapped to attr2- val2

RB3 - key2select 3 -mapped to attr3- val3

selectedkey -attr4 - {if RB1 is selected , this attribute will have value val1

if RB2 is selected , this attribute will have value val2

if RB3 is selected , this attribute will have value val3}

all RB will have a single selectedKey

Former Member
0 Kudos

Hello Dharma,

As far as I know KeyToSelect and SelectedKey properties are available only for a radiobutton and not for a table. However, this link may be of help to you.

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/ae/4d3b407b686913e10000000a1550b0/content.htm">http://help.sap.com/saphelp_nw04/helpdata/en/ae/4d3b407b686913e10000000a1550b0/content.htm</a>

Balakrishnan

Former Member
0 Kudos

Hi Saravanan,

create 2 context attributes say att1 and att2 of string type

create an attribute sel of string type

Assign some values for att1 and att2 say "a" and "b" .assign "a" for sel if you want first one checked

create 2 radio buttons

kettoselect of first button should be bound to att1 and

kettoselect of second button should be bound to att2

selectedkey of both should be bound to sel.

.At runtime whatever value you select will come to sel

you can access it by means of wdContext.currentContextElement.getsel()

Hope this helps you

Regards

Rohit

Message was edited by: Rohit Radhakrishnan