Welcome to the IBM Collaboration Solutions Community IQJam.
UsernamePassword
Reset Password | Register
   
Home | Leader Board | Tags | Help
Checkbox in repeater as "Select Document" 
Hi,
I have repeater that is binded to documentCollection. The panel inside is binded to a document.
The functionality I am trying to achieve is present list of documents and then make something with the ones user has selected. I have made checkbox in the repeater, but i don't have any idea how and  what to bind it. I can set value of this checkbox to documentunid, but I don't manage to collect wich checkboxes are cheked.
Will appreciate any help. Thank you.
Domino Development / XPages
Ana Dimova - about 1 year ago |  |  | Viewed 1057 times

There are 11 answers

0votes
It sounds like you need to have a look at the "checkbox group" control in the Controls --> Other... --> Other Controls section. This allows you to link check boxes together and treat them as a single control in HTML terms.
 
Matt 


Matt White - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
Matt's correct, and you'll want to make the data source for the group a scoped variable, that way you can access the selections server side by referencing the scoped var.


Jeremy Hodge - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
Actualy in checkbox group you can't insert tags different from "select item", so that is why you can't make checkbox in a repeater be part of some major checkbox group outside the repeater.
I have made some code on "on click" event of the checkbox that fills or empties sessionScope variable and it works. There is a code in "default check" property of the checkbox that computes based on that sessionscope variable.

I thought there can be easier way with some kind of built-in tools to perform that, but....
 
Thanks for your attention.


Ana Dimova - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
Hello Ana,
 
Could you tell me how did you do that? I 'm facing the same problem,I would like to display my checkboxes into 3 columns and the checkBoxGroup doesn't allow this : only one line or one column), so I would liket to use a repeat, but I can't get selected values (to bind them bind to the corresponding field in the document).
 
Thank you! 


Cedric Cisse - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


1votes
"product" is the data source of the panel inside repeater...
Sure you it can be done better way, but that is my way.

CheckBox Name: selectDoc
"Checked by default" formula:

var thisunid=product.getDocument().getUniversalID();
var selected=sessionScope.selectedDocs;
@If(@Contains(selected, thisunid), true, false);

Event on click: 

var thisunid=product.getDocument().getUniversalID();
var selected=sessionScope.selectedDocs;
if (sessionScope.selectedDocs){
    var newval=@If(@Contains(selected, thisunid),  @ReplaceSubstring(selected, thisunid,""),selected+"_"+thisunid);
    }else{
      newval = thisunid;}
sessionScope.selectedDocs=@Implode(@Trim(@Explode(newval,"_")),"_");



Ana Dimova - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


2votes
!!!I have made a correction in the above code - the if statement. 
 
"product" is the data source of the panel inside repeater...
Sure you it can be done better way, but that is my way.

CheckBox Name: selectDoc
"Checked by default" formula:

var thisunid=product.getDocument().getUniversalID();
var selected=sessionScope.selectedDocs;
@If(@Contains(selected, thisunid), true, false);

Event on click: 

var thisunid=product.getDocument().getUniversalID();
var selected=sessionScope.selectedDocs;
if (!sessionScope.selectedDocs==null){
    var newval=@If(@Contains(selected, thisunid),  @ReplaceSubstring(selected, thisunid,""),selected+"_"+thisunid);
    }else{
      newval = thisunid;}
sessionScope.selectedDocs=@Implode(@Trim(@Explode(newval,"_")),"_");



Ana Dimova - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
That's exactly what I needed, thank you for help,

Cedric Cisse - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
I've gotten this far using basically the same teqnique, but I'm stuck trying to create a "Select All..." action button.  Has anyone had success?
 
I can update the selectedDocs variable in the action, but the checkboxes do not reflect the change.  It's almost like the "Checked by default" is being ignored when the action is clicked.  I do not have this problem when using a DataTable rather than a Repeat control, but I have not been able to create dynamic columns with a DataTable and I need that.


Bill Hanson - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
Hi Bill,
As the poject went by we have learned a lot. Just before the checkbox we have addd computed field that sets the checkbox on and off according to the session variables.
The formula of the computed field is

var thisunid=product.getDocument().getUniversalID();

var selected=sessionScope.selectedDocs;

getComponent(

"selectDoc").setValue(thisunid);

}else{

getComponent("selectDoc").setValue('');

}

And on the checkbox we have left only "Value when checked" formula:
 

product.getDocument().getUniversalID();

And of course the onClick event 
And so here is the result of our efforts. http://shop.ibs.bg
 

 


Ana Dimova - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
Thanks Ana,
 
I solved this in a very similar manner.  Basically I use a requestScope variable and a bit of beforePageLoad code to set my default selection.


Bill Hanson - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
do you have to do something to use an Array in the sessionScope? 
 
I've tried this code, and it seems to be working except only one UIND is getting saved in the scope. Every time I click another checkbox it overwrites the previous values.
 Thanks!


David Leedy - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community