PDA

View Full Version : [FNR] Portal drag drop startColumn initialization error when column spacing = 0



Calone
11 Oct 2011, 5:07 AM
When you reduce the column spacing of a portal to 0, Drag and drop start column is not correctly initialized.
In the following example if you drag a portlet from the 2nd column to the first, the start column displayed will be 0 instead of 1.

The explanation is that the coordinates of the start of the drag event is exactly at the limit of the column, and the getColumn method of the portal class uses a greater than sign instead of a greater or equals sign



private int getColumn(int x) {
x += XDOM.getBodyScrollLeft();
for (int i = startColumns.size() - 1; i >= 0; i--) {
if (x > startColumns.get(i)) {
return i;
}
}
return 0;
}
- GXT 2.2.3
- Host mode
- Firefox 5
- win XP



package port.client;


import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.PortalEvent;
import com.extjs.gxt.ui.client.widget.custom.Portlet;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class Test implements EntryPoint {

public void onModuleLoad() {
com.extjs.gxt.ui.client.widget.custom.Portal portal = new com.extjs.gxt.ui.client.widget.custom.Portal(3) ;
portal.setBorders(true);
portal.setStyleAttribute("backgroundColor", "white");
portal.setColumnWidth(0, 320);
portal.setColumnWidth(1, 320);
portal.setColumnWidth(2, 310);
portal.setSpacing(0);
Portlet portlet = new Portlet();
portlet.setHeading("Grid in a Portlet");
portlet.setHeight(250);

portal.add(portlet, 0);

portlet = new Portlet();
portlet.setHeading("Another Panel 1");
portal.add(portlet, 0);

portlet = new Portlet();
portlet.setHeading("Panel 2");
portal.add(portlet, 1);

portlet = new Portlet();
portlet.setHeading("Another Panel 2");
portal.add(portlet, 1);

portlet = new Portlet();
portlet.setHeading("Panel 3");
portal.add(portlet, 2);

portal.addListener(Events.Drop, portletDragnDropListener);

RootPanel.get().add(portal);
}

private Listener<PortalEvent> portletDragnDropListener = new Listener<PortalEvent>()
{
public void handleEvent(PortalEvent be)
{
Window.alert("From -> ["+be.getStartColumn()+" , "+be.getStartRow()
+"] \nTo -> ["+ be.getColumn()+" , "+be.getRow()+"]");
}
};
}

sven
11 Oct 2011, 5:19 AM
Fixed in SVN as of revision 2471