• How to control the target database for documents opened from ViewGrid

    By Dale Manolas 9 years ago

    I'm trying to keep all of my XPages in one database and avoid all the problems that come from jumping between XPages in different databases.
    I have the OpenNTF v1.5 ViewGrid on an XPage in my “Activities” database.
    The ViewGrid is displaying a view in my “Contacts” database.
    When I click on a row the document opens in an XPage in the “Contacts” database.
    What I want is to have the document open in an XPage in the “Activities” database.
    Something like this would be ideal:
    Using the onRowClick event to somehow get the document UNID into a sessionScope variable and then opening a Contact.xsp XPage in the Activities database.
    The Contact.xsp would then get the document data from the “Contacts” database using the UNID stored in the sessionScope variable.
    Perhaps there is an easier/better approach than this? I don't know. Any help you could give to point me in the right direction would be appreciated.

    • By F. Kranenburg 9 years ago

      The easiest way (and in this case the fastest way) is to pass the documentid via an url parameter to “Contact.xsp”. For example you can generate a link like “Contact.xsp?OpenXpage?mydocumentid=“. Inside the Contact.xsp use “param.mydocumentid” SSJS code to retrieve the documentid. So, it doesn't need to be stored inside the sessionScope, but ofcourse you can store it inside the sessionScope inside your Contact.xsp if that is really needed (it doubt that).

      • By Dale Manolas 9 years ago

        Thank you for the prompt reply! I really appreciate it. I've worked all weekend on this and I am making some progress. My problem is that I display many document types in the ViewGrid. This means that I need to get the UNID from the ViewGrid and then figure out which XPage to open. I am doing this by putting the UNID into a field bound to a sessionScope “docUNID” variable. I then fire the click event of a button that submits the XPage. The navigation for the next XPage to open is computed. The code here gets the NotesDocument by UNID and then gets the FORM item value. It decides which XPage to open based on the FORM. When the XPage opens (in the same db) it is set to get data from the other database and the document ID to open is set to the “docUNID” sessionScope variable. This part all works well. The problem I am stuck on is to do with using the onRowClick event of the ViewGrid. I created a CSJS script library with a simple test function:

        function openDoc(){

        var vgID = '#{id:ViewGrid}' + '_widget';    
        var vgwidget = dijit.byId(vgID);
        alert(vgwidget.getSelection(true));
        //code to populate the field and click the button will go here
        

        }
        I then put openDoc(); into the onRowClick property of the ViewGrid. Unfortunately this causes the openDoc() function to fire when the XPage is loading and then the ViewGrid fails to load. It seems that I don't understand how the onRowClick property should be used. I've been banging my head against this problem for hours with no progress. I'm new to this (as you can guess) so any help at all with this problem would be really appreciated. Thanks!

        • By F. Kranenburg 9 years ago

          The cause of “openDoc” fireing onload is probably you specified “openDoc()” as the onRowClick property instead of “openDoc”. Is this the case?