PDA

View Full Version : "unselect all" for checkboxes in a grid...


cashmanbd
05-02-2005, 06:49 AM
I have a grid with a gridcolumn that specifies a Checkbox binded to boolean XML attribute using $path{}. Obviously, the checkboxes are replicated for each element in the grid’s contentpath.

I've been trying to implement a basic select/deselect buttons for the checkboxes within my grid, but so far I've been unsuccessful.

I've tried using javascript to modify the XML data the checkboxes bind, but since $path{} only constrains at startup, the checkboxes don't reflect the update.
I searched the docs for information on how the replication manager works with a grid, but didn't have any luck.

Any suggestions would be greatly appreciated.

cashmanbd
05-03-2005, 07:22 AM
In case anyone else runs into this...

I actually ended up creating my own grid-type class so I could use the replication manager to access the view that is replicated for each row. The replicated view has a checkbox and a series of static text elements.

To do "unselect all" I use the following script:

var nextClone = cloned_view.getCloneNumber(count);
do
{
var theCheckBox = nextClone.searchSubnodes('value', true);
if ( theCheckBox != null )
{
theCheckBox.setAttribute('value', false);
}// end if
nextClone = cloned_view.getCloneNumber(count++);
} while (nextClone != null )

I'm sure there HAS to be a better way to do this... if someone finds it, please post it in this thread.

Thanks,
-B

bhuwantiwari
06-16-2006, 05:22 AM
Hi,

I found the answer you posted close to my problem, could u please help me in my following problem.

I have grid which is dispalying file name, factor and checkbox in seperate column. I want to submit all file names to JSP page correspoding to selected checkbox. my question is:

1) How to associate checkbox with file (I know one possible way is to include filename in datapath of checkbox, I am looking for disassociating both. But if not found another way I am still fine with this.

2) Bigger problem is how to grab the value of selected checkbox and pass associated file names to JSP page.

There is an example in chapter 34 of user guide but not sure how to implement it in my case, tried many ways but no success yet.

Any help will be appreciated

I am adding snippet of code:

<view name="cel_file" width="100" height="300">
<simplelayout axis="y" spacing="5"/>
<grid multiselect="false" name="cel_file_list" bgcolor="0x8000ff" clip="true">
<gridtext editable="false" datapath="@name" name="Cel_file">Cel File
</gridtext>
<gridtext editable="false" datapath="@factor" name="Factor">Factor
</gridtext>
<gridcolumn>Select
<checkbox xoffset="${10-parent.width/2}">
</checkbox>
</gridcolumn>
</grid>
<button isdefault="true" text="Submit" ></button>
</view>

Thanks
Bhuwan

takekurox
01-16-2007, 11:13 PM
I have the same problem and resolve like followings.
This sample is for ALL SELECT.


<method event="onclick" >
<![CDATA[
// getting record count
var count = grid_id.getNumItems();
// if no record ...return
if (count==0) return;

// rounding all items.
for (var i=0; i<count; i++)
{
// check values on.
var chk = grid_id.getItemAt(i).subviews[1];
chk.setValue(true); <--------* (1) *
}
]]>
</method>


you can do UNSELECT by replacing *(1)* as follows

chk.setValue(false);

I hope this will help you.
Thanks.