This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Mar 13, 2013, 2:46 PM
7 Posts
topic has been resolvedResolved

Mark check boxes in viewPanel1 programatically

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags: xpages,viewpanel,getSelectedDocuments
  • Replies: 3
I need to mark check boxes in viewPanel1 based on selection of comboBox value.
 
For example, I have a view of Customer Order documents and I need to select all of the orders that are "Pending". The end user could scroll down the screen and check mark each row that has a status of "Pending", but there may be 50 scattered throughout the view.  I would like to have a comboBox where the end user could select "Pending" and xPages would check mark all the matching documents for them.  Then I have a button that would use .getSelectedIds() to act on those documents.
 
I have tried using rowData.setSelected (true), but this does not show a check mark in the viewColumn for the row.
 
Is there a way to access the xpage default checkbox in the viewPanel.
Mar 13, 2013, 5:25 PM
586 Posts
Re: Mark check boxes in viewPanel1 programatically
Tyler - 
 
I added this post to StackOverFlow as well.   
 
I'm not a big fan of the View Control.  I'm sure what you describe can be done but I'll offer an alternative approach.

I did this video showing a way to kinda of do a getSelectedIDs() from a repeat control:
http://xpages.tv/xtv3.nsf/episode_user.xsp?action=openDocument&documentId=94A

In that example the user could click on a row and I would add that ID to a map in sessionScope I think.  Maybe viewScope - I forget.  I used CSS to highlight the row to show it was selected.  There was a button that removed the id from the map and refreshed to remove the highlight.

Now what you want to do - let's forget checkboxes for now.  You should be able to use this repeat control technique then above your repeat have a button like Select all Pending.  That button would run a SSJS function that would loop through your data on the backend and get the correct UNIDS and then add them to the map.  A Partial refresh of the repeat would show them all selected.  Another button that needs to act on the selected list would then just reference that map of the ID's.

Where I used css to highlight the row I imagine you could have a checkbox control and of that particular row was in the map - add the check, otherwise leave it empty.

Anyway - that's one way to approach it that you should be able to get working on short order.

Really if you're using a view control I guess you could still have a button that got the documents via the backend and do similar processing.  In that case you might not need to add that check the the view since the selection is hard coded in reality. I guess the question is if you still need to mark them if you have that hard coded button.

 
Mar 14, 2013, 11:20 PM
366 Posts
Re: Mark check boxes in viewPanel1 programatically
 This is doable, but I don't understand why you are having them selected in a series of other documents when when they select drop down it would filter the view to only show the documents of a specific status and then operate on that document collection.
 
Is there a reason that they need to see all the other documents ? 
Mar 27, 2013, 1:08 PM
7 Posts
Re: Mark check boxes in viewPanel1 programatically
Paul,

 

The reason I needed the other documents to be on the screen is that the user may select all documents in a certain category, and then add to that collection 5 or 6 more documents, before acting on them.  So this type of "bulk selection" is an easier way for the user to select the first 50 records they need and then select the other 5 or 6 by hand.


Using some tidbits from David Leedy's response I was able to create a solution by keeping a collection of selected UNID's in a scope variable, using a java.util.ArrayList


// in the postOpenView of the custom control I put...
if (sessionScope.myList==null) {
    var myList = new java.util.ArrayList();
    sessionScope.put('myList',myList);
}

// in the onchange event of my combobox I put the following code,
// and set the partial update to viewPanel1
var myArray = sessionScope.get("myList");
var keycode;
var vp:com.ibm.xsp.component.xp.XspViewPanel = getComponent("viewPanel1");

for(i=0; i < vp.getRowCount() ; i++){

    vp.setRowIndex(i);
    var rowData=vp.getRowData();

    keycode = rowData.getUniversalID();
   

    //my combobox is bound to the sessionScope viewFilter
    var test1 = sessionScope.get("viewFilter")==" "; //(used for select all)
    var test2 = rowData.getColumnValue("$3").toString().startsWith(sessionScope.get("viewFilter"));

    if (test2 || test1) {

        if (!myArray.contains(keycode)) {
            myArray.add(keycode);
        }
   
    } else {
        myArray.remove(keycode);
    }
 

  I also added a column to the view with a faux checkbox (which is just cosmetic) where I can select additional rows to add (or remove) from "myArray"
 
 
// the onclick event of my faux checkbox column
// with partial update set to viewPanel1
 
 
var myArray = sessionScope.get("myList");
var keycode = rowData.getUniversalID();

if (!myArray.contains(keycode)) {
    myArray.add(keycode);
} else {
    myArray.remove(keycode);
}
 

Thanks for all the help!

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal