【问题标题】:Setting ListGrid selection in SmartGWT在 SmartGWT 中设置 ListGrid 选择
【发布时间】:2011-03-07 21:17:36
【问题描述】:

我正在尝试在 SmartGWT 中设置 ListGrid 表对象的选定记录,但我找不到任何方法。我知道有一个 getSelectedRecords() 函数,但没有匹配的 setSelectedRecords()。我试图查看 set/getSelectedState() 是否可以工作,但 GWT 抱怨需要主键和 DataSource 对象。有没有办法设置 ListGrid 的选择?

【问题讨论】:

    标签: gwt smartgwt


    【解决方案1】:

    为此,您可以使用selectRecords() 方法之一,如下所示:

    public void onModuleLoad() 
    {
        VLayout main = new VLayout();
        final ListGrid grid = new ListGrid();
        grid.setHeight(500);
        grid.setWidth(400);
        grid.setFields(new ListGridField("name", "Name"));
        grid.setData(createRecords());
    
        final IButton button = new IButton("Select some");  
        button.addClickHandler(new ClickHandler() {  
            public void onClick(ClickEvent event) 
            {  
              grid.selectRecords(new int[]{2, 3}); //This will select index 2 and 3
            }  
        });  
    
        main.addMember(grid);
        main.addMember(button);
        RootPanel.get().add(main);
    }
    
    private ListGridRecord[] createRecords() 
    {
        return new ListGridRecord[]{
          createRecord("monkey"),
          createRecord("banana"),
          createRecord("orange"),
          createRecord("sun")
        };
    }
    
    private ListGridRecord createRecord(String name) 
    {
        ListGridRecord record = new ListGridRecord();
        record.setAttribute("name", name);
        return record;
    }
    

    【讨论】:

    • 呃。为什么他们似乎在向我隐藏功能?谢谢。
    • @therin 我懂那种感觉,这些界面真的很臃肿,不协调。很高兴我能帮上忙。
    猜你喜欢
    • 2012-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多