我有一个Gwt celltable.单击标题可以正确排序列.但是在页面加载时,默认情况下不对列进行排序.我想在页面加载时使最右边的列排序.
作为后续行为,为什么在CellTable中没有使用CompositeCell的正常例子?
我正在尝试添加JSR-303验证支持.我在这里遵循了Koma的配置建议:如何使用gwt-2.4.0安装gwt-validation(注意:我使用GWT 2.4的内置验证,而不是GWT-Validation).
同样,为了获得一些重用,我制作了一对类,ValidatableInputCell和AbstractValidatableColumn.我从以下方面获得灵感:
我们来看看他们......
public class ValidatableInputCell extends AbstractInputCell<String, ValidatableInputCell.ValidationData> {
interface Template extends SafeHtmlTemplates {
@Template("<input type=\"text\" value=\"{0}\" size=\"{1}\" style=\"{2}\" tabindex=\"-1\"></input>")
SafeHtml input(String value, String width, SafeStyles color);
}
private static Template template;
/**
* The error message to be displayed as a pop-up near the field
*/
private String errorMessage;
private static final int DEFAULT_INPUT_SIZE = 15;
/**
* Specifies the width, in characters, of …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将a转换cellTable
为a datagrid
,因为我想稍后添加一个搜索处理程序,因此我需要修复列标题.目前我扩展celltable
/ datagrid
class并将小部件放入a simplelayoutpanel
并将其添加到我的tabpanel
.
如果我使用celltable
,一切正常,数据显示.如果我将类的类型更改为datagrid
,则数据有时会显示(列名始终存在).添加到我使用的表setRowData
或a dataProvider
.如果我设置断点以延迟加载表内容,则表有时会包含数据.如果我稍后调用表的重绘方法,该表将显示正确的信息.但该表应自动加载内容.在我的项目的其他"位置",我也使用了数据网格并且它可以工作Dialogboxes
.
我认为项目的绘制肯定存在错误,因为如果我调用.getRowCount
表或弃用.getDisplayedItems
,它会返回表中应该有正确数量的项目.此外,如果我向表中添加选择模型并选择项目,则该项目包含有效数据.
如果我在MyView.ui.xml UiBinder文件中定义我的CellTable,如下所示:
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:c="urn:import:com.google.gwt.user.cellview.client"
ui:generateFormat='com.google.gwt.i18n.rebind.format.PropertiesFormat'
ui:generateKeys='com.google.gwt.i18n.rebind.keygen.MD5KeyGenerator'
ui:generateLocales='default' xmlns:p1="urn:import:com.google.gwt.user.cellview.client">
...
<g:HTMLPanel>
<c:CellTable
addStyleNames='{style.cellTable}'
pageSize='15'
ui:field='cellTable' width="100%">
</c:CellTable>
</g:HTMLPanel>
Run Code Online (Sandbox Code Playgroud)
然后programmaticaly将列添加到CellTable,一切正常.
但是为了减少样板代码,我想在我的UiBinder文件中定义表列.我试过这个:
...
<g:HTMLPanel>
<c:CellTable
addStyleNames='{style.cellTable}'
pageSize='15'
ui:field='cellTable' width="100%">
<c:TextColumn
addStyleNames='{style.titleColumn}'
ui:field="titleColumn"/>
</c:CellTable>
</g:HTMLPanel>
Run Code Online (Sandbox Code Playgroud)
但它会产生以下错误:
[ERROR] [dialective] - 找到意外的子元素Element addStyleNames ='{style.titleColumn}'ui:field ='titleColumn'>(:33)
如何使用UiBinder定义整个CellTable?
当使用TableBuilder
创建行和亚行,如预期选择模型不能正常工作.单击子视图的复选框时,未选择该行,但是,将选择父行.
我尝试过载onBrowserEvent
的CheckboxCell
,以人工处理的选择,但似乎在DataGrid本身按checkboxcell时触发选择事件.
如果行和子行来自相同类型,如何添加支持行和子行的选择模型?
我有一个CellTable,它有4列:
| Column 1 | Column 2 | Column 3 | Column 4 |
Run Code Online (Sandbox Code Playgroud)
目标:
用户可以在按住鼠标按钮并将鼠标悬停在列上时选择多个列.
例如,用户单击第1列并按住鼠标按钮,在第2列和第3列上移动,从而选择第2列和第3列.
我试过了:
final MultiSelectionModel<data> selectionModel = new MultiSelectionModel<BestellungData>();
cellTable.setSelectionModel(selectionModel);
cellTable.addCellPreviewHandler(new Handler<data>()
{
@Override
public void onCellPreview(
CellPreviewEvent<data> event) {
// TODO Auto-generated method stub
if ("click".equals(event.getNativeEvent().getType())) {
selectionModel.setSelected(event.getValue(), true);
}
}
});
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我正在尝试创建一个包含一些文本和一个复选框的列的CellTable,它将用作全选复选框(参见下图,"cb"是复选框).目前我正在使用从Header派生的类并覆盖它的render方法来输出文本和一个复选框.我重写onBrowserEvent()但它只给我onChange事件,除了复选框无法正常工作外,它会正常工作.有没有人对此有任何想法?
+-------+------------+
| col 1 | Select All |
| | cb |
+-------+------------+
| row 1 | cb |
+-------+------------+
Run Code Online (Sandbox Code Playgroud)
我在复选框中遇到的问题是,如果没有选中,则必须单击两次以显示复选标记(至少在Chrome上),即使第一次"已检查"属性为真.单击一下即可正确取消选中它.
这是一些代码:
/** Setup the table's columns. */
private void setupTableColumns() {
// Add the first column:
TextColumn<MyObject> column1 = new TextColumn<MyObject>() {
@Override
public String getValue(final MyObject object) {
return object.getColumn1Text();
}
};
table.addColumn(macColumn, SafeHtmlUtils.fromSafeConstant("Column1"));
// the checkbox column for selecting the lease
Column<MyObject, Boolean> checkColumn = new Column<MyObject, Boolean>(
new CheckboxCell(true, false)) {
@Override
public Boolean …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个由TextCell和ButtonCell组成的CompositeCell.我想通常将CompositeCell添加到Column,然后将Column添加到CellTable.但是,我无法弄清楚列的实例应该如何.特别是我在以下代码中找不到它的类型参数:
Column<FilterInfo, ?> compositeColumn = new Column<FilterInfo, ?>(createCompositeCell()) {
@Override
public Object getValue(Object object) {
// TODO Auto-generated method stub
return null;
}};
Run Code Online (Sandbox Code Playgroud)
创建自定义类FilterInfo的CompositeCell的方法(是否必要?)是:
private CompositeCell<FilterInfo> createCompositeCell(){
HasCell<FilterInfo, String> filterName = new HasCell<FilterInfo, String>() {
public Cell<String> getCell() {
return new TextCell();
}
public FieldUpdater<FilterInfo, String> getFieldUpdater() {
// TODO Auto-generated method stub
return null;
}
public String getValue(FilterInfo object) {
return object.getFilterName();
}};
HasCell<FilterInfo, String> filterButton = new HasCell<FilterInfo,String>(){
public Cell<String> getCell() {
return new ButtonCell();
}
public FieldUpdater<FilterInfo, …
Run Code Online (Sandbox Code Playgroud) 我想让行中的某些单元格不可编辑.到现在我的解决方案是当我创建列时,如果一个是readOnly,则创建一个TextCell,如果没有,我使用默认的Cell,可以是EditTextCell,DatePickerCell等.
这个问题是我不能把一些行readOnly和其他行没有.或者他们是所有字段readOnly或他们不是.
我该怎么做才能做到这一点
表:
Data1 | Data2 | Data3
--------------------------------------
readOnly | non-readOnly | readOnly
readOnly | readOnly | 非readOnly的
当我的意思是"readOnly"时,它可以"启用"或使其成为"TextCell"
celda = new TextInputCell();
Column<ObjetoDato, String> columna = new Column<ObjetoDato, String>(celda) {
@Override
public String getValue(ObjetoDato object) {
if(actual.getValorDefault()!=null && object.getValor(actual.getNombreCampo()).isEmpty()){
object.setValor(actual.getNombreCampo(), actual.getValorDefault());
return actual.getValorDefault();
}
return object.getValor(actual.getNombreCampo());
}
};
tabla.agregarColumna(columna, actual.getCaption());
columna.setFieldUpdater(new FieldUpdater<ObjetoDato, String>() {
@Override
public void update(int index, ObjetoDato object, String value) {
object.setValor(actual.getNombreCampo(), value);
new Scripter(object,actual.getComportamiento(),true);
tabla.actualizar();
Sistema.get().getIG().actualizarTotales();
}
});
Run Code Online (Sandbox Code Playgroud)
我已经尝试创建我的cutom单元并替换TextImputCell,但方法永远不会触发
celda = new FabriCel(); …
Run Code Online (Sandbox Code Playgroud) 我有一个组合框,它由一个文本字段和一个带有显示建议项的CellTable的弹出窗口组成.文本字段有一个更改处理程序,用于更新CellTable的选择.
键入字符并单击已选择的建议时,将吞下第一次单击.第二次单击工作并通过CellTable.addDomHandler(...)触发选择.
知道为什么第一次点击被吞下了吗?
示例代码:
private static class SuggestFieldTextAndPopupSandbox extends SimplePanel {
private final TextField mText;
private CellTable<Handle<String>> mTable;
private SingleSelectionModel<Handle<String>> mTableSelection;
private SingleSelectionModel<Handle<String>> mSelection;
private ProvidesKey<Handle<String>> mKeyProvider = new SimpleKeyProvider<Handle<String>>();
private PopupPanel mPopup;
private List<Handle<String>> mData;
public SuggestFieldTextAndPopupSandbox() {
mData = Lists.newArrayList(new Handle<String>("AAA"), new Handle<String>("AAB"), new Handle<String>("ABB"));
mSelection = new SingleSelectionModel<Handle<String>>();
mText = new TextField();
mText.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent pEvent) {
mPopup.showRelativeTo(mText);
}
});
mText.addBlurHandler(new BlurHandler() {
@Override
public void onBlur(BlurEvent pEvent) {
mTableSelection.setSelected(startsWith(mText.getValue()), true);
}
}); …
Run Code Online (Sandbox Code Playgroud)