cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robby Pelssers <robby.pelss...@agp.nl>
Subject RE: CForms repeater with Ajax problem
Date Fri, 26 Oct 2007 00:45:39 GMT
 
Hi Gary,
 
Could you give it a try by using following snippet?
 
<fd:booleanfield id="archiveVersionSelect">

    <fd:on-value-changed>

        <fd:javascript>

            var source = event.getSourceWidget();

           //if checkbox checked we need to take action -> set other
checkboxes to false

           if (source.getValue().booleanValue()) {

               var row = source.getParent();

               var rowId = row.getId();

               var repeater = row.getParent();

               //don't check state of other checkboxes...just set them
to false

               for (var i = 0; i &lt; repeater.getSize(); i++) {

                   if (i != rowId) {

 
repeater.getRow(i).lookupWidget("archiveVersionSelect").setValue(false);

                   }

               } 

           }

        </fd:javascript>

     </fd:on-value-changed>

</fd:booleanfield>

 
Cheers,
Robby Pelssers
 
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
----------
 

Hi Robin,

 

Not as much luck with this one but I can live without Ajax if this is
not possible.  Setting the widget to invisible or disabled before
setValue() had no effect on the Ajax handling.

 

If you have the time to take a look, the code below works without Ajax,
making sure the unselected row widgets are set to false.  

 

<fd:booleanfield id="archiveVersionSelect">

    <fd:on-value-changed>

        <fd:javascript>

            var source = event.getSourceWidget();

            var row = source.getParent();

            var rownum = row.getName();

            cocoon.log.warn("source row: " + rownum + " value: " +
source.getValue());

            if (source.getValue() == 'true') {

                var repeater = row.getParent();

                for (var i = 0; i &lt; repeater.getSize(); i++){

                    if (i != rownum) {

                        if
(repeater.getRow(i).getChild("archiveVersionSelect").getValue() ==
'true') {

                            cocoon.log.warn("row set to false: " + i);

 
repeater.getRow(i).getChild("archiveVersionSelect").setValue(false)

                        }

                    }

                }

            }

        </fd:javascript>

     </fd:on-value-changed>

</fd:booleanfield>

 

Here's the log (without Ajax) where initially row 0 is true and row 1 is
clicked:

 

WARN  [http-8080-Processor25] flow 2007-10-23 16:11:24,863 - source row:
1 value: true

WARN  [http-8080-Processor25] flow 2007-10-23 16:11:24,863 - row set to
false: 0

WARN  [http-8080-Processor25] flow 2007-10-23 16:11:24,863 - source row:
0 value: false

 

This is the log with Ajax:

 

WARN  [http-8080-Processor23] flow 2007-10-23 16:10:04,581 - source row:
1 value: true

WARN  [http-8080-Processor23] flow 2007-10-23 16:10:04,581 - row set to
false: 0

WARN  [http-8080-Processor23] flow 2007-10-23 16:10:04,581 - source row:
0 value: false

WARN  [http-8080-Processor24] flow 2007-10-23 16:10:04,753 - source row:
0 value: true

WARN  [http-8080-Processor24] flow 2007-10-23 16:10:04,753 - row set to
false: 1

WARN  [http-8080-Processor24] flow 2007-10-23 16:10:04,753 - source row:
1 value: false

 

Even though the log says rows 0 and 1 are set to false they are still
checked on the screen.  

 

Thanks,

gary

 

________________________________

From: Robin Wyles [mailto:rob@robinwyles.com] 
Sent: Tuesday, October 23, 2007 10:43 AM
To: users@cocoon.apache.org
Subject: Re: CForms repeater with Ajax problem

 

Gary, me again!

 

Quick thought - have you tried setting the state of the repeater to
invisible at the start of your action triggered by the on-change event,
and then back to active again at the end? I've often found this to sort
out ajax updates in a repeater where you are updating widgets in
different rows.

 

If this doesn't help maybe you could post the relevant parts of your
form definition and template and the action code too.

 

Robin

 

On 23 Oct 2007, at 15:10, Gary Larsen wrote:





I'm using Cocoon 2.1.9.  I have a repeater grid where each row contains
a booleanfield to select a row.

 

My problem is I only want one row selected at a time.  Without Ajax the
on-change event I created will successfully toggle off other rows when
one is selected.  With Ajax turned on it seems like there is a cascade
effect going on, the result is the other rows are not being turned off.

 

Perhaps there is another way to implement a grid like this which will
work with Ajax?

 

Thanks for any suggestions.

gary





 


Mime
View raw message