我使用GXT 3.0.5(商业许可)。
当我使用GridInlineEditing
创建网格时,仅在Chrome上存在一些奇怪的错误:
使用setCLicksToEdit(ONE)
时,无法编辑列(出现版本组件,然后立即消失)
使用setCLicksToEdit(TWO)
,我可以编辑除包含CheckBox
的列以外的所有列:出现CheckBox
,但是单击它时,版本完成,并且值未更新。
我创建了一个带有Grid的小示例,该Grid多次显示此Bean:
public class MyBean {
private Integer id;
private String label;
private Boolean enabled;
public MyBean(Integer id, String label, Boolean enabled) {
this.id = id;
this.label = label;
this.enabled = enabled;
}
//Getters & Setters
}
并对应网格。我使它尽可能简单:
public class MyGrid extends Composite {
public interface MyPropertyAccess extends PropertyAccess<MyBean> {
ValueProvider<MyBean, Integer> id();
ValueProvider<MyBean, String> label();
ValueProvider<MyBean, Boolean> enabled();
}
public MyGrid(){
//Build columnModel
MyPropertyAccess propertyAccess = GWT.create(MyPropertyAccess.class);
ColumnConfig<MyBean, Integer> colId = new ColumnConfig<MyBean, Integer>(propertyAccess.id(),500, "ID");
ColumnConfig<MyBean, String> colLabel = new ColumnConfig<MyBean, String>(propertyAccess.label(), 500, "Label");
ColumnConfig<MyBean, Boolean> colEnabled = new ColumnConfig<MyBean, Boolean>(propertyAccess.enabled(), 500, "Enabled");
ColumnModel<MyBean> columnModel = new ColumnModel<MyBean>(Arrays.<ColumnConfig<MyBean,?>>asList(colId, colLabel, colEnabled));
//Create grid
Grid<MyBean> grid = new Grid<MyBean>(new ListStore<MyBean>(buildModelKeyProvider()), columnModel);
//Make it editable
GridInlineEditing<MyBean> inlineEditing = new GridInlineEditing<MyBean>(grid);
inlineEditing.addEditor(colLabel, new TextField());
inlineEditing.addEditor(colEnabled, new CheckBox());
inlineEditing.setClicksToEdit(ClicksToEdit.TWO);
//Fill store with dummy values
for(int i = 1;i<=30;i++){
grid.getStore().add(new MyBean(i, "Bean"+i, i%2==0));
}
this.initWidget(grid);
}
private ModelKeyProvider<MyBean> buildModelKeyProvider(){
return new ModelKeyProvider<MyBean>() {
@Override
public String getKey(MyBean item) {
return Integer.toString(item.getId());
}
};
}
}
我做错了什么还是GXT中存在错误?
注意:我可以将
GridInlineEditing
替换为GridRowEditing
(它可以工作),但这不再满足用户的需求。注意:在Firefox上,
setCLicksToEdit(ONE)
也有相同的问题,但是setCLicksToEdit(TWO)
一切都很好 最佳答案
签出http://dev.sencha.com/deploy/ext-4.0.0/examples/grid/row-editing.html
这是GXT的较新版本,但是您可以看到在提交更改时复选框没有更新。这似乎是GXT中的错误。
这可以帮助您解决第一个问题:http://www.sencha.com/forum/showthread.php?266458-GridInlineEditing-fires-blur-event-immediately-after-cliking