Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to prevent portlets from dropping at a specific position

    SmartClient Version: v9.1p_2015-09-16/Pro Development Only (built 2015-09-16)
    Any supported browser (any version?), i.e., Google Chrome

    I have two portlets in a PortalLayout. I would like to prevent any portlets from dropping before Portlet #1. I want Portlet #1 to always be at the first index. Using Portlet's "canDropBefore" prevented the drop line from showing but Portlet #2 is still able to drop over it even without the drop line. Would this be a bug with canDropBefore or am I missing something?
    Code:
    isc.PortalLayout.create({
        canAcceptDrop: true,
        portlets: [
            isc.Portlet.create({
                title: "Portlet 1",
                canAcceptDrop: false,
                canDrop: false,
                canDropBefore: false,
                canDragReposition: false,
                items: [
                    isc.Canvas.create({
                        backgroundColor: "blue"
                    })
                ]
            }),
            isc.Portlet.create({title: "Portlet 2"})
        ]
    });

    #2
    canDropBefore won't work as you expect, because there are some intermediate internal structures in a PortalLayout.

    However, you can achieve what you want by implementing 'willAcceptPortletDrop' on the PortalLayout. For instance, consider this modified version of your example:

    Code:
    isc.PortalLayout.create({
        canAcceptDrop: true,
        width: 640,
        height: 480,
        portlets: [
            isc.Portlet.create({
                title: "Portlet 1",
                canAcceptDrop: false,
                canDrop: false,
                canDragReposition: false,
                items: [
                    isc.Canvas.create({
                        backgroundColor: "blue"
                    })
                ]
            }),
            isc.Portlet.create({title: "Portlet 2"}),
            isc.Portlet.create({title: "Portlet 3"})
        ],
        willAcceptPortletDrop: function (dragTarget, colNum, rowNum, dropPosition) {
            if (colNum == 0 && rowNum == 0) {
                return false;
            } else {
                return this.Super("willAcceptPortletDrop", arguments);
            }
        }
    });
    You should be able to drag Portlet 2 or Portlet 3 above and below each other, but you shouldn't be able to drag either of them above (or beside) Portlet 1.

    Comment


      #3
      Hi
      I have added 6 portlets in PortletLayout. On dragging the portlets the position of the portlets change. I want to know the new position of the portlet but could not find any help. I need to save the position of the portlet so that on page refresh of the browser the position can be retained.
      I am not able to achieve this. Please let me know if is it feasible and how

      Comment


        #4
        Why are you saying you don't know the portlet's position when in the code right above you can see that rowNum and colNum and dropPosition are passed to you?

        Also, there is a sample of portal layout persistence right in the Feature Explorer.

        If you continue to post questions where it is clear you have not made an attempt to use the docs and samples to answer your own question, please do not expect further response from Isomorphic. Please see also the FAQ for further advice on how best to get attention to questions when you have not purchased a Support contract.

        Comment


          #5
          Hi Isomorphic,

          I am facing a strange issue in com.smartgwt.client.widgets.layout.PortalLayout and com.smartgwt.client.widgets.layout.Portlet. I have some portlet distributed in PortalLayout in four columns. I can drag and drop portlets from one column to another column and in another row as well. I don't want multiple portlets in a single column horizontally. To be very specific I want a single portlet in a single cell. Is there any way I can achieve this. I have gone through PortalLayout and Portlet documents, I didn't get any property or method to achieve this.
          I have attached an Image here explaining the issue. Please help. Please let me know if any further clarification is required.
          Attached Files
          Last edited by ankulchoudhary; 22nd Jun 2017, 04:41.

          Comment

          Working...
          X