Drag 'n Drop - ListGrid rows not being displayed

SmartGWT EE 2.5 (March 1st build)
Firefox 3.6.16

Following the showcase example for Drog’nDrop . Problem is the list grids don’t display any rows even though the listGrid.getTotalRows() function returns the correct counts. What am I missing ?

EntryPoint code

public class StandAloneCase implements EntryPoint {
  
    public void onModuleLoad() {

    	
        HStack hStack = new HStack(10);
        hStack.setHeight(160);

        final ListGrid myList1 = new ListGrid();
        myList1.setCanDragRecordsOut(true);
        myList1.setCanAcceptDroppedRecords(true);
        myList1.setCanReorderFields(true);
        myList1.setDragDataAction(DragDataAction.MOVE);
        myList1.setData(PartData.getRecords());
        hStack.addMember(myList1);

        final ListGrid myList2 = new ListGrid();
        myList2.setCanDragRecordsOut(true);
        myList2.setCanAcceptDroppedRecords(true);
        myList2.setCanReorderRecords(true);

        VStack vStack = new VStack(10);
        vStack.setWidth(32);
        vStack.setHeight(74);

        GWT.log("count is " + myList1.getTotalRows());


        hStack.addMember(vStack);
        hStack.addMember(myList2);

        hStack.draw();   




    }
}

Here are the data structures (from showcase)

package com.reliable.app.client.forms;

import com.reliable.app.client.forms.PartRecord;

public class PartData {

    private static PartRecord[] records;

    public static PartRecord[] getRecords() {
        if (records == null) {
            records = getNewRecords();
        }
        return records;
    }

    public static PartRecord[] getNewRecords() {
        return new PartRecord[]{
                new PartRecord("Blue", "cube_blue.png", 1),
                new PartRecord("Yellow", "cube_yellow.png", 2),
                new PartRecord("Green", "cube_green.png", 3),
                new PartRecord("Blue", "cube_blue.png", 4),
                new PartRecord("Yellow", "cube_yellow.png", 5),
                new PartRecord("Green", "cube_green.png", 6),
                new PartRecord("Blue", "cube_blue.png", 7),
                new PartRecord("Yellow", "cube_yellow.png", 8),
                new PartRecord("Green", "cube_green.png", 9),
        };
    }
}
package com.reliable.app.client.forms;

import com.smartgwt.client.widgets.grid.ListGridRecord;

public class PartRecord extends ListGridRecord {

    public PartRecord() {
    }

    public PartRecord(String partName, String partSrc, int partNum) {
        setPartName(partName);
        setPartSrc(partSrc);
        setPartNum(partNum);
    }

    public void setPartName(String partName) {
        setAttribute("partName", partName);
    }

    public void setPartSrc(String partSrc) {
        setAttribute("partSrc", partSrc);
    }

    public void setPartNum(int partNum) {
        setAttribute("partNum", partNum);
    }
}

Well the first problem would be that the grid has neither fields nor a DataSource so it doesn’t know what to show.

Thanks for the feedback, however what about the myList1.setData(…) line ? Isn’t that what achieves it in this particular use case (at list for the myList1 grid)? The code base was borrowed from the showcase sample http://www.smartclient.com/smartgwt/showcase/#effects_dd_move_list which doesn’t set the data source (unless done in the PartListGrid definition ).

Ok. I have made some adjustments to allow for client side datasource. See below :

   public void onModuleLoad() {
        HStack hStack = new HStack(10);
        hStack.setHeight(160);

        final ListGrid myList1 = new ListGrid();
        myList1.setCanDragRecordsOut(true);
        myList1.setCanAcceptDroppedRecords(true);
        myList1.setCanReorderFields(true);
        myList1.setDragDataAction(DragDataAction.MOVE);
        myList1.setDataSource(PartDS.getInstance());
        myList1.setAutoFetchData(true);
        myList1.setData(PartData.getRecords());

        hStack.addMember(myList1);



        VStack vStack = new VStack(10);
        vStack.setWidth(32);
        vStack.setHeight(74);

        GWT.log("MYLIST1 count is " + myList1.getTotalRows());


        hStack.addMember(vStack);


        hStack.draw();   
    }

The PartRecord

import com.smartgwt.client.widgets.grid.ListGridRecord;

public class PartRecord extends ListGridRecord {

    public PartRecord() {
    }

    public PartRecord(String partName) {
        setPartName(partName);
    }

    public void setPartName(String partName) {
        setAttribute("partName", partName);
    }

}

The PartData (only one field)

import com.reliable.app.client.forms.PartRecord;

public class PartData {

    private static PartRecord[] records;

    public static PartRecord[] getRecords() {
        if (records == null) {
            records = getNewRecords();
        }
        return records;
    }

    public static PartRecord[] getNewRecords() {
        return new PartRecord[]{
                new PartRecord("Blue"),
                new PartRecord("Yellow"),
                new PartRecord("Green"),
                new PartRecord("Blue"),
                new PartRecord("Yellow"),
                new PartRecord("Green"),
                new PartRecord("Blue"),
                new PartRecord("Yellow"),
                new PartRecord("Green"),
        };
    }
}

And finally the DS

public class PartDS extends DataSource {

    private static PartDS instance = null;

    public static PartDS getInstance() {
        if (instance == null) {
            instance = new PartDS("partDS");
        }
        return instance;
    }

    public PartDS(String id) {

        setID(id);
        DataSourceTextField partNameField = new DataSourceTextField("partName", "Name");
        
        
        setFields(partNameField); 
        setClientOnly(true);
    }


    @Override
    protected Object transformRequest(DSRequest dsRequest) {
        return super.transformRequest(dsRequest);
    }
}

Still no luck returning the rows. However the counts returned by GWT.log() is fine.

I know I am missing something as showcase works. Let me know.