on 08-15-2006 8:32 AM
Hi everyone,
I created a radiobutton in each row of a table.
When I click on a button, I want to know on which row and what are the data of this row.
How it can be done ?
Thanks.
Assign an action to the RadioButton.<i>onSelect</i> event with a parameter "selectedElement" of type I<Rows>Element, where "Rows" is the name of the table data source node.
Map (implicit) event parameter "nodeElement" to action parameter "selectedElement" like this:
wdDoModifyView():
if (firstTime)
{
IWDRadioButton rb = (IWDRadioButton) view.getElement("ID-of-radio-button");
rb.mappingOfOnSelect().addSourceMapping
(
"nodeElement", "selectedElement"
);
}
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
Here is a nice guide to provide this feature:
The context:
- Persons (Node)
-- Name (Attribute)
-- SelectedKey (Attribute, String)
-- Selection (Node, cardinality: 0..1, selection: 1..1, supplyFuntion selectPerson)
--- KeyToSelect (Attribute, String)
Layout:
- Add table with dataSource propertie: Persons
- Tablerow TextView with propertie text: Persons.Name
- Tablerow RadioButton with propertie keyToSelect: Persons.Selection.KeyToSelect, selectedKey: Persons.SelectedKey, onSelect: SelectPerson
Code:
public void selectPerson(......) {
ISelectionElement el = node.createSelectionElement();
node.addElement(el);
el.setKeyToSelect(parentElement.getName());
}
public void onActionSelectPerson(.....) {
for (int i=0; i < wdContext.nodePersons().size(); i++) {
if (i != wdContext.nodePersons().getLeadSelection()) {
wdContext.nodePersons().getElementAt(i).setAttributeValue("SelectedKey", null);
}
}
}
Method above is for not getting a multiple select (work-around)
If you have a button in your layout that submits the selection, you can read the selected row with:
String key = wdContext.nodePersons().currentPersonsElement().getSelectedKey();
wdComponentAPI.getMessageManager().reportSuccess(key);
Regards,
Björn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
It is superfluous to use radiobuttons inside table cells for the scenario you describe.
When you bind the table to a node with cardinality (0-n), and set the selectionmode to single, you can allways access the data for that row from the context:
wdContext.current<NodeName>Element.getProperty();
Good luck,
Roelof
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.