【发布时间】:2012-12-03 17:39:16
【问题描述】:
我是 GXT 新手,我正在尝试在 3.0.1 版本上执行此操作:
我有一个基于 showcase example 的可编辑网格,我已经修改了使用 SimpleComboBox 的列的代码,因为我需要像正常情况一样处理要显示的值和 id HTML,我找不到使用 SimpleComboBox 的方法。
现在我正在使用 ComboBoxCell 和 ComboBox 来实现这一点,但我有两个问题。
问题 #1
当表格显示时,组合列不会像内联编辑列那样呈现(如示例中的列)。 下面是创建列的代码:(ObjectDTO只有id和value属性)
public class MyGrid implements IsWidget {
private GridEditing<MyGridDTO> columnEditing;
//another variables needed to create and handle the grid
public MyGrid(){
List<ColumnConfig<MyGridDTO, ?>> listColumns = new ArrayList<ColumnConfig<MyGridDTO, ?>>();
sm.setSelectionMode(SelectionMode.SINGLE);
//...
ColumnConfig<MyGridDTO, ObjectDTO> colsomeProperty = new ColumnConfig<MyGridDTO, ObjectDTO>(
properties.someProperty(),170,cons.gbsomePropertyTitle());
//...
ComboBoxCell<ObjectDTO> somePropertyCell = new ComboBoxCell<ObjectDTO>(somePropertysStore,new LabelProvider<ObjectDTO>() {
public String getLabel(ObjectDTO item) {
return item.getDescripcion();
}
});
listColumns.add(colSomeProperty);
colSomeProperty.setCell(somePropertyCell);
final ComboBox<ObjectDTO> combo = new ComboBox<ObjectDTO>(somePropertyCell);
columnEditing.addEditor(colSomeProperty,combo);
columnEditing.addBeforeStartEditHandler(new BeforeStartEditHandler<MyGridDTO>() {
public void onBeforeStartEdit(BeforeStartEditEvent<MyGridDTO> event) {
//handle whether or not to allow column editing
}
});
}
}
在我遇到问题 #2 之前,这没什么大不了的
问题 #2
我必须根据我要编辑的行将网格中的某些列设为只读。我通过在 MyGridDTO 中拥有一个属性来做到这一点,该属性是布尔值,并确定我是否可以编辑此对象。问题是:在编辑组合框列时,没有任何 gridEditingevents 上升,我认为这种行为是因为组合框已经可见,而不是在内联编辑属性后面“隐藏”。我的意思是,因为它已经可见,所以 GridEting 不再应该处理编辑事件。这可能吗?
此时我不知道该怎么做,因为我找不到解决方法。我不确定这方面的信息是否如此之少,或者我的研究方式是否错误(很可能)
有什么线索吗?
PD:请为我的英语道歉。
【问题讨论】: