on 09-11-2007 2:02 PM
Hi all,
for example, i want to create 3 radio buttons in one group & 3 radio buttons in another group. after creating radio buttons in two groups dynamically, if i select one radio button in group1, the first radio button in the group2 must be selected automatically. pls tell me the code for this.
thanks & regards,
vila
For creation of dynamic radio button you need to create element in WDDoModifyView()
IWDRadioButton radio = (IWDRadioButton)view.createElement(IWDRadioButton.class,"RadioButton1");
radio.set<property>(<value>);
These are the 3 preperties maily used in case of radiobutton.
KeyToSelect: Unique key which which this radio button will be identified while selection from a number of radiobutton.s
SelectedKey: This property is set to the key of the radiobutton that is currently selected.
OnSelect: An event that you want to fire when the radio button is selected.
Assume you have 2 radio button RB1 and RB2
Properties of RB1
KeyToSelect: Key_1
SelectedKey: context attribute (Ctx_SelectedKey) type String
OnSelect: Action1
Properties of RB2
KeyToSelect: Key_2
SelectedKey: context attribute (Ctx_SelectedKey) type String
OnSelect: Action2
Note: selectedKey is binded to the same context as you want to consider them as a single group.
If you want to set that RB1 should be selected by default when the application is executed.
you can write this in wdDoInit()
wdContext.currentContextElement().setCtx_SelectedKey("Key_1");
If you want that on the selection of 1st radio button in first group the 1st radio button of the 2nd group should be selected then you can check the currently selected key attribute Ctx_SelectedKey as mentioned above and based on that you can set the Ctx_SelectedKey2 for the second group of radio button.
Regards,
Murtuza
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
well I usually use standard radiobuttons, never created them dynamically.
but in you case I'd suppose you do the following:
create 6 value attributes in context, for example rb_option_1, rb_option_2, ... of type string
create one value attribute "selected"
bind all radio buttons property "selected_key" to the "selected" context attribute.
and each radiobutton "keyToSelect" to its rb_option_x
I always use coded keys, which are constants.
private final static String RB_OPTION_1 = "one";
private final static String RB_OPTION_2 = "two";
...
then fill the context attributes
wdcontext.currentContexElement().setRb_option_1(RB_OPTION_1);
wdcontext.currentContexElement().setRb_option_2(RB_OPTION_2);
...
now the selected radio button defines the context attribute content of "selcted". you can access it via code.
String selected = wdcontext.currentContexElement().getSelected();
if you want that radio button 2 activates radiobutton 3, I propose you just give them the same constant
private final static String RB_OPTION_2 = "two";
private final static String RB_OPTION_3 = RB_OPTION_2;
the radio buttons are not directly cuppled I think, so this should work.
cheers
stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.