我正在使用:SmartGwt 3.0;重量 2.4; 火狐 11 和谷歌浏览器 19.0.1084.52。
首先我要为我的英语道歉,因为它非常糟糕。我需要的是在listgrid 的单元格中拖放一个组件(例如标签、图像等...)。我知道您可以拖动记录,但我想在单元格中添加任何类型的组件。感谢任何帮助,无论多么小,否则我将创建一个表格组件,它具有大量属性 listgrid,您可以在其中添加一个单元格中的组件。事实并没有解决问题。
我正在使用最新版本的 smartgwt
我正在试验方法“getShowRecordComponents”、“getShowRecordComponentsByCell”、“WillAcceptDrop”和“CreateRecordComponent”。我必须拖放一个组件 smartgwt(通过先前的配置),但我在记录的末尾 Arreaga,我希望你把它放在你放置组件的列行中。
这个类在其他类中被调用。
private class CustomList extends ListGrid{
//record que hace el drop
private ListGridRecord currentRecord = null;
//elemento que se va a dropear
private Canvas currentCanvas = null;
//private int index;
public CustomList() {
this.setHeight(400);
this.setWidth(400);
this.setCanResizeFields(true);
this.setResizeFieldsInRealTime(true);
this.setShowRecordComponentsByCell(true);
this.setShowRecordComponents(true);
this.setCanAcceptDrop(true);
this.addRecordDropHandler(new RecordDropHandler() {
@Override
public void onRecordDrop(RecordDropEvent event) {
System.out.println("X: " + event.getX());
System.out.println("Y: " + event.getY());
System.out.println("index: " + event.getIndex());
System.out.println("event.getDropRecords() ==> "+ event.getDropRecords());
//guardamo el record y el canvas que se hace el drop
currentRecord = event.getTargetRecord();
currentCanvas = EventHandler.getDragTarget();
}
});
//defino columna ico
ListGridField field = new ListGridField("icon");
ListGridField field2 = new ListGridField("valor");
this.setFields(field, field2);
//añado record para poder aceptar drops
ListGridRecord record = new ListGridRecord();
ListGridRecord record2 = new ListGridRecord();
record.setCanAcceptDrop(true);
record.setAttribute("icon", "Hola");
record.setAttribute("valor", "adios");
record2.setAttribute("icon", "Segundo");
record2.setAttribute("valor", "Segundo Adios");
this.addData(record);
this.addData(record2);
}
//la llamada a createRecordComponent la hace el listgrid al crearse.
@Override
protected Canvas createRecordComponent (ListGridRecord record, Integer colNum) {
System.out.println("record: " + record);
System.out.println("colNum: " + colNum);
System.out.println("currentRecord: " + currentRecord);
if (record.equals(currentRecord)) {
System.out.println("createRecordComponent - REGRESARA: " + currentCanvas);
return currentCanvas;
}
return null;
}
@Override
public Boolean willAcceptDrop(){
return true;
}
@Override
public Canvas updateRecordComponent (ListGridRecord record, Integer colNum, Canvas component, boolean recordChange) {
System.out.println("***************************************************************************************");
System.out.println("Estoy en gridView");
System.out.println("***************************************************************************************");
System.out.println("record es : "+record);
System.out.println("colNum es : "+colNum);
System.out.println("component es : "+component);
System.out.println("recordChange es :"+recordChange);
System.out.println("***************************************************************************************");
return component;
}
}
你能帮助我吗??