[CLOSED] [1.0]Moving Portlet from Portal to Portal

  1. #1

    [CLOSED] [1.0]Moving Portlet from Portal to Portal

    Scenario:
    2 portals; Portal1 has 2 Portlets, 2 column layout, one portlet per column; Portal2 has 0 Portlets, 2 column layout;

    Action:
    Drag Portlet1 (column 0) from Portal1 into Portal2 (column 1)

    Caveat:
    Leave Portlet1 in Portal1 and actually drop(load) a new copy of Portlet1 into Portal2

    In experimenting with this operation it appears that I am only dragging a mask over to Portal2 from Portal1. If I don't move Portlet1 over a valid droptarget, Portlet1 will remain in it's original position in Portal1. Is there a way I can use Portal2's drop event (or other event occuring prior to drop) to load a new copy of Portlet1 into Portal2 and leave the original Portlet1 in it's original position in Portal1?

    Other sugestions to accomplish the same end result are welcome.

    The screen shot of a mockup page is a simple visual representation of what I described above.
  2. #2

    RE: [CLOSED] [1.0]Moving Portlet from Portal to Portal

    Hi,

    Please see the following sample (left and right portals can copy portlets to the center portal)
    <%@ Page Language="C#" %>
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>  
        
        <script type="text/javascript">
            function duplicatePortlet(e){
                /*
                    e : {
                        portal,
                        panel,
                        columnIndex,
                        column,
                        position,
                        data,
                        source,
                        rawEvent,
                        status
                    }
                */
                
                if(e.portal == e.panel.ownerCt.ownerCt){
                    return true;
                }
                
                var panel = Ext.ComponentMgr.create(Ext.apply(e.panel.initialConfig, {id: Ext.id()}), "portlet"),
                    pos = e.position,
                    c = e.column,
                    portal = e.portal;
                
                if(pos !== false){
                    c.insert(pos, panel);
                }else{
                    c.add(panel);
                }
    
                c.doLayout();
    
                portal.fireEvent('drop', e);
    
                var st = portal.dd.scrollPos.top;
    
                if (st) {
                    var d = portal.body.dom;
                    setTimeout(function () {
                        d.scrollTop = st;
                    }, 10);
                }
    
                portal.items.each(function (x) {
                    x.doLayout();
                });
                
                return false;
            }        
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
            <ext:Viewport runat="server" Layout="HBox">
                <LayoutConfig>
                    <ext:HBoxLayoutConfig Padding="10" Align="Stretch" />
                </LayoutConfig>
                <Items>
                    <ext:Portal ID="LeftPortal" runat="server" Border="false" Layout="Column" Flex="1">
                        <Items>
                            <ext:PortalColumn 
                                runat="server" 
                                ColumnWidth="1"
                                >
                                <Items>
                                    <ext:Portlet ID="Portlet1" runat="server" Title="Another Panel 1" />
                                    <ext:Portlet ID="Portlet2" runat="server" Title="Another Panel 2" />
                                    <ext:Portlet ID="Portlet3" runat="server" Title="Another Panel 3" />
                                </Items>
                            </ext:PortalColumn>                        
                        </Items>
                        <Listeners>
                            <ValidateDrop Handler="return e.portal == e.panel.ownerCt.ownerCt;" />
                        </Listeners>
                    </ext:Portal>
                    
                    <ext:Portal ID="CenterPortal" runat="server" Layout="Column" Flex="1">     
                         <Items>
                            <ext:PortalColumn 
                                runat="server" 
                                ColumnWidth="1"
                                >                           
                            </ext:PortalColumn>                        
                        </Items>  
                        <Listeners>
                            <BeforeDrop Fn="duplicatePortlet" />
                        </Listeners>            
                    </ext:Portal>
                    
                    <ext:Portal ID="RightPortal" runat="server" Border="false" Layout="Column" Flex="1">
                        <Items>
                            <ext:PortalColumn 
                                runat="server" 
                                ColumnWidth="1"
                                >
                                <Items>
                                    <ext:Portlet ID="Portlet4" runat="server" Title="Another Panel 4" />
                                    <ext:Portlet ID="Portlet5" runat="server" Title="Another Panel 5" />
                                    <ext:Portlet ID="Portlet6" runat="server" Title="Another Panel 6" />
                                </Items>
                            </ext:PortalColumn>                        
                        </Items>
                        <Listeners>
                            <ValidateDrop Handler="return e.portal == e.panel.ownerCt.ownerCt;" />
                        </Listeners>
                    </ext:Portal>
                </Items>
            </ext:Viewport>
        </form>
    </body>
    </html>
    Vladimir Shcheglov
    Sr. Developer
  3. #3

    RE: [CLOSED] [1.0]Moving Portlet from Portal to Portal



    Thank you very much for the time spent creating this solution.

    This is an excellent solution to the problem given!

    Mark as [CLOSED]

Similar Threads

  1. [CLOSED] MVC Portal / Portlet RenderExtPartial Issue
    By paulc in forum 1.x Premium Help
    Replies: 2
    Last Post: Feb 10, 2011, 8:04 PM
  2. Replies: 0
    Last Post: Mar 03, 2010, 10:51 AM
  3. Replies: 0
    Last Post: Aug 24, 2009, 5:03 AM
  4. Need help setting the Height on Dynamic Portal/Portlet
    By iansriley in forum 1.x Premium Help
    Replies: 1
    Last Post: Mar 03, 2009, 6:38 AM
  5. Portal, Portlet & Viewstate
    By Kalitte in forum Bugs
    Replies: 4
    Last Post: Dec 30, 2008, 5:27 AM

Posting Permissions