2
下一个接收焦点我使用GWT 2.1.0指定哪些细胞应在一CellTable
我有一个CellTable填充的是使用不同的细胞来编辑不同类型的值(例如,日期,串等等)列。我希望用户能够在单元格中单击,键入一个值,然后按Enter键直接编辑下一个单元格,或者直接单击选项卡编辑下一个单元格。
我一直在寻找Cell和CellTable接口,但找不到任何看起来相关的东西。我怎样才能达到这个效果?
下一个接收焦点我使用GWT 2.1.0指定哪些细胞应在一CellTable
我有一个CellTable填充的是使用不同的细胞来编辑不同类型的值(例如,日期,串等等)列。我希望用户能够在单元格中单击,键入一个值,然后按Enter键直接编辑下一个单元格,或者直接单击选项卡编辑下一个单元格。
我一直在寻找Cell和CellTable接口,但找不到任何看起来相关的东西。我怎样才能达到这个效果?
我有类似的要求,我找不到一个开箱即用的解决方案。我结束了继承TextInputCell并自己添加tabIndex支持。
这里有一些小部分的子类(希望它会编译,懒得检查)。不幸的是,我不能发布整个子类,因为它有很多可能与当前问题无关的其他事情。该解决方案负责切换到下一个单元格,但对于输入支持,您可能需要重写onBrowserEvent。
public class EditTextInputCell extends TextInputCell
{
int startTabIndex;
interface TabbedTemplate extends SafeHtmlTemplates
{
@Template("<input type=\"text\" value=\"{0}\" tabindex=\"{1}\" class=\"{2}\" title=\"{3}\"></input>")
SafeHtml input(String value, String tabindex, String styleClass, String title);
}
private static TabbedTemplate template;
public EditTextInputCell(int startTabIndex)
{
this.startTabIndex = startTabIndex;
}
@Override
public boolean isEditing(Context context, Element parent, String value)
{
return true;
}
@Override
public void render(Context context, String value, SafeHtmlBuilder sb)
{
// Get the view data.
Object key = context.getKey();
ValidationData viewData = getViewData(key);
if (viewData != null && value.equals(viewData.getCurrentValue()))
{
clearViewData(key);
viewData = null;
}
String strToDisp = (viewData != null && viewData.getCurrentValue() != null) ? viewData.getCurrentValue() : value;
String tabIndex = "" + startTabIndex + context.getIndex() + context.getColumn();
boolean invalid = (viewData == null) ? false : viewData.isInvalid();
String styleClass = "cellTableCell-valid";
String errorMessage = "";
if (invalid)
{
styleClass = "cellTableCell-invalid";
errorMessage = viewData.getMessage();
}
if (strToDisp != null)
{
SafeHtml html = SimpleSafeHtmlRenderer.getInstance().render(strToDisp);
// Note: template will not treat SafeHtml specially
sb.append(getTemplate().input(html.asString(), tabIndex, styleClass, errorMessage));
}
else
{
sb.appendHtmlConstant("<input type=\"text\" tabindex=\"" + tabIndex + "\" class=\"" + styleClass + "\" title=\"" + errorMessage + "\"></input>");
}
}
private TabbedTemplate getTemplate()
{
if (template == null)
{
template = GWT.create(TabbedTemplate.class);
}
return template;
}}