我在SmartGWT中有一個數據源。我如何從中提取數據?我一直在使用fetchData()
方法試過,但隨後在標準我需要添加一個值即如何提取數據源中的所有數據?
Criteria cr = new Criteria();
cr.addCriteria("Name", "Name_Value");
爲了執行對數據源做什麼我需要做全選?
下面是代碼:
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.DragDataAction;
import com.smartgwt.client.widgets.TransferImgButton;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.HStack;
import com.smartgwt.client.widgets.layout.VStack;
import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeGrid;
import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.widgets.tree.TreeGridField;
public class TreeDragNodesSample implements EntryPoint {
TreeGrid grid1 = new TreeGrid();
TreeGrid grid2 = new TreeGrid();
String name=null;
public void onModuleLoad() {
Tree test = new Tree();
grid1.setDragDataAction(DragDataAction.COPY);
grid1.setAutoFetchData(true);
grid1.setDataSource(EmployeeXmlDS.getInstance());
grid1.setWidth(200);
grid1.setHeight(200);
grid1.setShowEdges(true);
grid1.setBorder("0px");
grid1.setBodyStyleName("normal");
grid1.setShowHeader(false);
grid1.setLeaveScrollbarGap(false);
grid1.setEmptyMessage("<br>Drag & drop parts here");
grid1.setManyItemsImage("cubes_all.png");
grid1.setAppImgDir("icons/16/");
grid1.setNodeIcon("cube.png");
grid1.setFolderIcon("person.png");
grid1.setCanReorderRecords(true);
grid1.setCanAcceptDroppedRecords(true);
grid1.setCanDragRecordsOut(true);
grid1.setCanAcceptDrop(true);
grid1.setCanDrop(true);
TreeGridField tname = new TreeGridField("Name");
TreeGridField child = new TreeGridField("ChildID");
TreeGridField reps = new TreeGridField("ReportsTo");
grid1.setFields(tname);
grid2.setLeft(250);
grid2.setAutoFetchData(true);
grid2.setDataSource(EmployeeXmlDSDrop.getInstance());
grid2.setWidth(200);
grid2.setHeight(200);
grid2.setShowEdges(true);
grid2.setBorder("0px");
grid2.setBodyStyleName("normal");
grid2.setShowHeader(false);
grid2.setLeaveScrollbarGap(false);
grid2.setEmptyMessage("<br>Drag & drop parts here");
grid2.setManyItemsImage("cubes_all.png");
grid2.setAppImgDir("icons/16/");
grid2.setNodeIcon("cube.png");
grid2.setFolderIcon("person.png");
grid2.setCanReorderRecords(true);
grid2.setCanAcceptDroppedRecords(true);
grid2.setCanDragRecordsOut(true);
grid2.setCanAcceptDrop(true);
grid2.setCanDrop(true);
TreeGridField tname2 = new TreeGridField("Name");
TreeGridField child2 = new TreeGridField("ChildID");
TreeGridField reps2 = new TreeGridField("ReportsTo");
grid2.setFields(tname2);
VStack moveControls = new VStack(10);
moveControls.setWidth(32);
moveControls.setHeight(74);
moveControls.setLayoutAlign(Alignment.CENTER);
TransferImgButton rightArrow = new TransferImgButton(TransferImgButton.RIGHT, new ClickHandler() {
public void onClick(ClickEvent event) {
grid2.transferSelectedData(grid1);
}
});
moveControls.addMember(rightArrow);
TransferImgButton leftArrow = new TransferImgButton(TransferImgButton.LEFT, new ClickHandler() {
public void onClick(ClickEvent event) {
grid1.transferSelectedData(grid2);
}
});
moveControls.addMember(leftArrow);
HStack grids = new HStack(10);
grids.setHeight(160);
grids.addMember(grid1);
grids.addMember(moveControls);
grids.addMember(grid2);
grids.draw();
}
}
有像getAllRecords沒有方法() – 2012-03-15 10:21:48
哎呀,我的錯! API鏈接可以讓你使用正確的方法。無論如何,我用正確的方法名稱更新了我的答案。 – gpapaz 2012-03-15 10:29:30
即使getRecords()不起作用...文我使用這種方法獲取記錄整個項目停止工作.. – 2012-03-15 10:56:32