我使用 smartgwt 的 TileGrid。TileGrid 包含 300 条记录。例如,我选择 150 条记录并移至另一页。在这个TileGrid 中放置Canvas,并在模型中放置Canvas。当我回到上一页时,从模型中绘制 Canvas(和 TileGrid)。TileGrid 显示第一行,但如果您使用鼠标滚动,则 TileGrid 定位在之前选择的记录上。如何返回到旧页面立即定位在旧记录上
方法“getCentr(false)”包含抽象方法“getElement()”。方法“getShapka()”、“getPodval()”返回 Vlayout。NewHolst 类是模板视图。
public class VakansiSearchLayout extends NewHolst{
private List<ProfessiaBean> profBean = new ArrayList<ProfessiaBean>();
private List<ProfessiaBean> profBeanBufer = new ArrayList<ProfessiaBean>();
private VLayout content;
private TileGrid tileGrid;
public VakansiSearchLayout(MenuItem curentMenuItem, INotifier notifer)
{
super(curentMenuItem, notifer);
if (ModelVakansi.INST.getBuffer() == null)
poluchitProf();
else
{
content = (VLayout) ModelVakansi.INST.getBuffer();
tileGrid = (TileGrid) content.getMember(0);
}
{
addMember(getShapka());
addMember(getCentr(false));
addChild(getPodval());
}
if (ModelVakansi.INST.getBuffer() != null)
{
ModelVakansi.INST.setBuffer(null);
}
}
private void poluchitProf()
{
addDrawHandler(new DrawHandler()
{
@Override
public void onDraw(DrawEvent event)
{
// TODO Auto-generated method stub
SGWTRPCServletWithProgress.run(new Callback<List<ProfessiaBean>>()
{
@Override
public void run(List<ProfessiaBean> result)
{
if (result != null)
{
if (result.isEmpty())
{
}
else
{
profBean = result;
content.removeMembers(content.getMembers());
content.addMember(lookProf());
}
}
else
{
GuiContextInst.getInst().showWarn("Error");
}
}
@Override
public void error(Throwable caught)
{
check(caught);
}
private void check(Throwable caught)
{
runError(caught);
}
}, "wait", Actions.PROF, "");
}
});
}
@Override
protected Canvas getElement()
{
if (ModelVakansi.INST.getBuffer() != null)
{
// content = (VLayout) ModelVakansi.INST.getBuffer();
return content;
}
else
{
content = new VLayout();
content.setWidth100();
content.setHeight(centrHght+20);
content.setOverflow(Overflow.AUTO);
content.addMember(lookProf());
content.setScrollbarSize(0);
return content;
}
}
private Canvas lookProf()
{
tileGrid = new TileGrid();
tileGrid.setWidth(centrWdth + centrBlock);
tileGrid.setHeight(centrHght+20);
tileGrid.setTileWidth(370);
tileGrid.setTileHeight(92);
tileGrid.setStyleName("label_prof");
tileGrid.setCanReorderTiles(true);
tileGrid.setCanFocus(true);
tileGrid.setShowAllRecords(false);
tileGrid.setAutoFetchData(true);
tileGrid.setAnimateTileChange(true);
tileGrid.setData(getRecords());
tileGrid.setWrapValues(true);
tileGrid.setScrollbarSize(0);
tileGrid.setBorder("0px");
tileGrid.addClickHandler(new ClickHandler()
{
@Override
public void onClick(ClickEvent event)
{
ModelVakansi.INST.setBuffer(content);
notifer.notifyListeners(new Event(ru.my.web.client.Event.SELECT_PROF,
tileGrid.getSelectedRecord().getAttributeAsObject("code").toString()));
}
});
DetailViewerField name = new DetailViewerField("name");
tileGrid.setFields(name);
tileGrid.sortByProperty("name", true);
return tileGrid;
}
private ProfRecord[] getRecords()
{
int i = 0;
ProfRecord result[] = new ProfRecord[profBean.size()];
for (ProfessiaBean oneProfe : profBean)
{
result[i] = new ProfRecord(oneProfe.getName().toUpperCase(), oneProfe.getCode());
i++;
}
return result;
}
@Override
public void scrolToIframe(String id, int i)
{
tileGrid.scrollBy(0, i);
}}