Hi
I would like to create an action on a repeater that copies some of the values of a row into a group of other fields (the fields having similar sort of values). This action should take place when an action on a row is selected.

Here are the relevant parts of the code :
---

   <!-- INFORMATION REPEATER -->
   <fd:repeater id="information">
     <fd:label>Information</fd:label>
     <fd:widgets>
       <fd:output id="id">
         <fd:datatype base="integer"/>
       </fd:output>
<fd:booleanfield id="select"/> <fd:output id="position"><fd:datatype base="integer"/></fd:output>

       <fd:field id="heading" required="false">
         <fd:label>Heading</fd:label>
         <fd:datatype base="string"/>
       </fd:field>
<fd:field id="sub_heading" required="false">
         <fd:label>Sub Heading</fd:label>
         <fd:datatype base="string"/>
       </fd:field>
<fd:booleanfield id="list_item">
         <fd:label>Display text as bullet</fd:label>
       </fd:booleanfield>

       <fd:field id="text" required="false">
         <fd:label>Text</fd:label>
         <fd:datatype base="string"/>
       </fd:field>
<fd:field id="icompType">
           <fd:label>Type</fd:label>
           <fd:datatype base="string"/>
</fd:field> <fd:field id="icompCity">
           <fd:label>City</fd:label>
           <fd:datatype base="string"/>
</fd:field> <fd:field id="icompCode">
           <fd:label>Code</fd:label>
           <fd:datatype base="string"/>
</fd:field> <fd:field id="iname">
           <fd:label>Name</fd:label>
           <fd:datatype base="string"/>
</fd:field> <!-- Edit Information -->
       <fd:action id="edit_information" command="edit-information">
          <fd:label>Edit</fd:label>
          <fd:on-action>
           <fd:javascript>
                var selectedRow = event.source.getParent();
                var indexOfSelectedRow = selectedRow.getId();
var informEdit = event.source.getForm().getChild("info_edit"); selectedRow.lookupWidget("../../active_repeater").setValue("information"); selectedRow.lookupWidget("../../active_element").setValue(parseFloat(indexOfSelectedRow)); informEdit.getChild("heading_edit").setValue(selectedRow.getChild("heading").getValue()); informEdit.getChild("sub_heading_edit").setValue(selectedRow.getChild("sub_heading").getValue()); informEdit.getChild("sub_heading_edit").setValue(selectedRow.getChild("sub_heading").getValue()); informEdit.getChild("list_item_edit").setValue(selectedRow.getChild("list_item").getValue()); informEdit.getChild("text_edit").setValue(selectedRow.getChild("text").getValue()); informEdit.getChild("icompType_edit").setValue(selectedRow.getChild("icompType").getValue()); informEdit.getChild("icompCity_edit").setValue(selectedRow.getChild("icompCity").getValue()); informEdit.getChild("icompCode_edit").setValue(selectedRow.getChild("icompCode").getValue()); informEdit.getChild("iname_edit").setValue(selectedRow.getChild("iname").getValue()); informEdit.setState(WidgetState.ACTIVE);
           </fd:javascript>
          </fd:on-action>
       </fd:action>
     </fd:widgets>
</fd:repeater> <!-- END INFORMATION REPEATER -->

   <fd:group id="info_edit">
       <fd:widgets>
       <fd:field id="heading_edit" required="false">
         <fd:label>Heading</fd:label>
         <fd:datatype base="string"/>
       </fd:field>
<fd:field id="sub_heading_edit" required="false">
         <fd:label>Sub Heading</fd:label>
         <fd:datatype base="string"/>
       </fd:field>
<fd:booleanfield id="list_item_edit">
         <fd:label>Display text as bullet</fd:label>
       </fd:booleanfield>

       <fd:field id="text_edit" required="false">
         <fd:label>Text</fd:label>
         <fd:datatype base="string"/>
       </fd:field>
<fd:field id="icompType_edit">
           <fd:label>Type</fd:label>
           <fd:datatype base="string"/>
</fd:field> <fd:field id="icompCity_edit">
           <fd:label>City</fd:label>
           <fd:datatype base="string"/>
</fd:field> <fd:field id="icompCode_edit">
           <fd:label>Code</fd:label>
           <fd:datatype base="string"/>
</fd:field> <fd:field id="iname_edit">
           <fd:label>Name</fd:label>
           <fd:datatype base="string"/>
</fd:field> <!-- Edit Information -->
       <fd:action id="return_information" command="return-information">
          <fd:label>OK</fd:label>
          <fd:on-action>
           <fd:javascript>
// var selectedRepeater = event.source.lookupWidget("../../" + event.source.lookupWidget("../../active_repeater")); var selectedElement = event.source.lookupWidget("../../active_element");

var repeater = event.source.lookupWidget("../../information");

                var row = repeater.getRow(selectedElement);

                var informEdit = event.source.getParent();

row.getChild("heading").setValue(informEdit.getChild("heading_edit").getValue()); row.getChild("sub_heading").setValue(informEdit.getChild("sub_heading_edit").getValue()); row.getChild("list_item").setValue(informEdit.getChild("list_item_edit").getValue()); row.getChild("text").setValue(informEdit.getChild("text_edit").getValue()); row.getChild("icompType").setValue(informEdit.getChild("icompType_edit").getValue()); row.getChild("icompCity").setValue(informEdit.getChild("icompCity_edit").getValue()); row.getChild("icompCode").setValue(informEdit.getChild("icompCode_edit").getValue()); row.getChild("iname").setValue(informEdit.getChild("iname_edit").getValue()); informEdit.setState(WidgetState.INVISIBLE);
           </fd:javascript>
          </fd:on-action>
       </fd:action>
     </fd:widgets>
   </fd:group>

---
When I click on the action however, the fields that were displayed are blanked out and the fields in the group have no values in them. Am I missing something? We only display a subset of the rows in the group and the repeaters, would that have an affect? We are currently on cocoon 2.1.7.

TIA.

--
Kamal Bhatt



--
Disclaimer: This email is confidential and may contain privileged information 
for the sole use of the person or business to which it is addressed. If you are 
not the intended recipient, please notify the sender by return e-mail or phone 
as you must not view, disseminate, distribute or copy this email without our 
consent. We do not accept any liability in connection with any computer virus, 
data corruption, incompleteness, or unauthorised amendment of this email. It is 
the sole responsibility of the receiver to scan for viruses before opening.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to