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 14, 2011, 4:28 PM
66 Posts

Re: how to: delete documents from a repeat control

  • Category: Other
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags: repeat,delete,checkbox
  • Replies: 5
I've used the code below inside a view column for deleting specific documents. Might help you out.
 
<xp:link text=" Delete" id="link3">
                    <xp:eventHandler event="onclick" submit="true"
                        refreshMode="complete">
                        <xp:this.action>
                            <xp:actionGroup>
                                <xp:executeScript>
                                    <xp:this.script>
                                        <![CDATA[
                                #{javascript:
                                    var id = viewEntry.getUniversalID();
                                    var doc:NotesDocument = database.getDocumentByUNID(id);
                                    doc.remove(true);
                                    }
                                }                        
                            ]]>
                                    </xp:this.script>
                                </xp:executeScript>
                            </xp:actionGroup>
                        </xp:this.action>
                        <xp:this.script>
                            <xp:executeClientScript>
                                <xp:this.script><![CDATA[if (confirm("Delete worksheet?"))
                                 {
                                 return true;
                                 }
                                else {
                                return false;
                                 }]]></xp:this.script>
                            </xp:executeClientScript>
                        </xp:this.script>
                    </xp:eventHandler>
</xp:link>
Mar 14, 2011, 7:56 PM
39 Posts
Re: how to: delete documents from a repeat control
I was thinking something like this:
 
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
        <xp:this.resources>
        <xp:script src="/JSLibrary.jss" clientSide="false"></xp:script>
    </xp:this.resources>
   
   
    <xp:this.data>
        <xp:dominoView var="view1" viewName="view1"></xp:dominoView>
    </xp:this.data>
    <xp:table>
    <xp:repeat id="repeat1" rows="30" value="#{view1}" var="row">
    <xp:tr>
    <xp:td>
        <xp:checkBox text="" id="checkBox1">
            <xp:eventHandler event="onclick" submit="true"
                refreshMode="complete">
                <xp:this.action><![CDATA[#{javascript:Library.toggleSelected(row.getDocument().getUniversalID());}]]></xp:this.action>
            </xp:eventHandler></xp:checkBox>
    </xp:td>
    <xp:td>
   
        <xp:text escape="true" id="computedField1"
            value="#{row.field1}">
        </xp:text>
    </xp:td>
    <xp:td>   
                <xp:text escape="true" id="computedField2"
            value="#{row.field2}">
        </xp:text>
        </xp:td>
    </xp:tr>
    </xp:repeat>
    </xp:table>
    <xp:br></xp:br>
    <xp:br></xp:br>
    <xp:button value="Delete Selected" id="button1">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="complete">
            <xp:this.action><![CDATA[#{javascript:Library.deleteAllSelected();}]]></xp:this.action>
        </xp:eventHandler></xp:button>

</xp:view>

 function Library() {
}
Library.vec = new java.util.Vector();
Library.toggleSelected = function(id:string) {
    if (this.vec.contains(id)) {
            this.vec.remove(id);
    }
    else {
        this.vec.add(id);
    }
}
Library.deleteAllSelected = function() {
    var db:NotesDatabase = session.getCurrentDatabase();
    var doc:NotesDocument;
    for (i=0; i<this.vec.size(); i++) {
        doc = db.getDocumentByUNID(this.vec.elementAt(i));
        doc.remove(true);
        this.vec.remove(this.vec.elementAt(i));    
    }
    
}
Mar 15, 2011, 9:42 AM
178 Posts
thanks Toby (smalll comment)
this works great! the only comment I have that the checkbox gets checked for the next 'row' in the repeater after a deletion
Mar 15, 2011, 2:03 PM
39 Posts
Re: thanks Toby (smalll comment)
Yeah I see what your saying, Not sure what the best way is to handle this, one way to ensure that you get a fresh page session is to just do a context.redirectToPage() after it does the delete.  This would ensure you get a fresh set of variables.
 
Thanks
-Toby

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