Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

ListGrid backgroundComponent bug

$
0
0
I am trying to set up background components on certain list grid records in SmartGWT 4.0, and think I have found a bug in the code.

My test case starts with the showcase example ColumnOrderSample.

I replaced getViewPanel with the following code:

Code:

    public Canvas getViewPanel() {

        Canvas canvas = new Canvas();

        final ListGrid grid = new ListGrid();
        grid.setWidth(500);
        grid.setHeight(224);
        grid.setShowBackgroundComponent(true);

        ListGridField field1 = new ListGridField("field1", "Column 1", 100);
        ListGridField field2 = new ListGridField("field2", "Column 2");

        grid.setFields(field1, field2);
       
       
        grid.setData(new ListGridRecord[]{
                        buildRecord("dog","pet","#FF0000"),
                        buildRecord("cow","livestock","#FF8800"),
                        buildRecord("horse","livestock","#FFFF00"),
                        buildRecord("goldfish","pet","#FFFFFF"),
                        buildRecord("pig","livestock","#008800"),
                        buildRecord("lion","wild","#00FF88")
        });
        canvas.addChild(grid);

        return canvas;
    }
   
    public ListGridRecord buildRecord(String value1, String value2, String canvasColor) {
            ListGridRecord record = new ListGridRecord();
            record.setAttribute("field1", value1);
            record.setAttribute("field2", value2);
            Canvas c = new Canvas();
            c.setBackgroundColor(canvasColor);
            c.setWidth100();
            c.setHeight100();
            record.setBackgroundComponent(c);
            return record;
    }

None of my background components are showing.

Looking at the js and the java classes, it looks like the ListGrid.setShowBackgroundComponent(Boolean showBackgroundComponent) is setting the attribute "showBackgroundComponent", whereas the javascript is looking for attribute "showBackgroundComponents", with an s.

When I overrode ListGrid.setShowBackgroundComponent(Boolean showBackgroundComponent) to set "showBackgroundComponents" instead, the code works fine.

Code:

        final ListGrid grid = new ListGrid() {
                @Override
                public void setShowBackgroundComponent(Boolean showBackgroundComponent) {
                setAttribute("showBackgroundComponents", showBackgroundComponent, true);
                }
        };


Viewing all articles
Browse latest Browse all 4756

Trending Articles