tilegrid问题

时间:2012-12-07 05:03:14

标签: java smartgwt

我使用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);
}}

0 个答案:

没有答案