GWT EditTextCell:如何增加EditTextCell中可编辑文本框的宽度?

发布于 2024-12-20 23:34:32 字数 1379 浏览 5 评论 0原文

我在我的项目中使用GWT2.3。 当用户单击 editableTextCell 时,我想增加 editableTextBox 的宽度。 问题是我的列宽是 200 Px。当用户单击 editableTextCell 时,EditableTextCell 中的 TextBox 宽度约为 125px,与列宽度相比要小。

我在 Celltable 的列中添加了 EditTextCell

Column stringColumn = new Column(new EditTextCell()) { // 我的代码 cellTable.addColumn

(stringColumn, "MyColumn"); cellTable.setColumnWidth(checkBoxColumn, 200, Unit.PX);

我尝试了以下方法来增加 TextBox 宽度,但问题是我无法在文本框中编辑 + 焦点而不是丢失

    @Override
            public void onBrowserEvent(Context context, Element elem,Record object, NativeEvent event) {
                String type = event.getType();

                  int editedTexBoxSize = (cellTable.getOffsetWidth()-100)/cellTable.getColumnCount();

                  if(elem.getInnerHTML().startsWith("<INPUT")){
                      String test = elem.getInnerHTML();
                     // test = <INPUT tabIndex=-1 value=P __eventBits="2048"></INPUT>

                     test= test.replace("value", " size="+editedTexBoxSize+" value");


                    // test = <INPUT tabIndex=-1 size=131 value=P __eventBits="2048"></INPUT>


                      elem.setInnerHTML(test);
                  }
                super.onBrowserEvent(context, elem, object, event);
            }

我想增加(设置)EditTextCell 中出现的 TextBox 宽度等于列宽度。

有什么解决办法吗?

I am using GWT2.3 in my project.
I want to increase editableTextBox width when user click on editableTextCell.
Problem is My Column width is 200 Px. when user clicks on editableTextCell then that TextBox width is around 125px in EditableTextCell is less as compare to column width.

I added EditTextCell in Celltable's column

Column stringColumn = new Column(new EditTextCell()) {
// My Code
}

cellTable.addColumn(stringColumn, "MyColumn");
cellTable.setColumnWidth(checkBoxColumn, 200, Unit.PX);

I tried following way to increase TextBox width but problem is I cannot edit in textbox + focus not losses

    @Override
            public void onBrowserEvent(Context context, Element elem,Record object, NativeEvent event) {
                String type = event.getType();

                  int editedTexBoxSize = (cellTable.getOffsetWidth()-100)/cellTable.getColumnCount();

                  if(elem.getInnerHTML().startsWith("<INPUT")){
                      String test = elem.getInnerHTML();
                     // test = <INPUT tabIndex=-1 value=P __eventBits="2048"></INPUT>

                     test= test.replace("value", " size="+editedTexBoxSize+" value");


                    // test = <INPUT tabIndex=-1 size=131 value=P __eventBits="2048"></INPUT>


                      elem.setInnerHTML(test);
                  }
                super.onBrowserEvent(context, elem, object, event);
            }

I want to Increase(set) TextBox width appear in EditTextCell is equal to column Width.

Any Solution ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

花桑 2024-12-27 23:34:32

在我的项目中我这样做:

cellTable.getColumn(cellTable.getColumnIndex(column)).setCellStyleNames(CELL_CSS);

.edit-cell input {
    width: 290px;
}

In my project I do that:

cellTable.getColumn(cellTable.getColumnIndex(column)).setCellStyleNames(CELL_CSS);

.edit-cell input {
    width: 290px;
}
天赋异禀 2024-12-27 23:34:32

终于有答案了!
我使用 UIBinder 尝试了更简单的操作,添加了:

.edit-cell input {
    width: 30px;
    text-align: right;
}

然后对于单元格表,我添加了

 <c:CellTable
        addStyleNames='{style.edit-cell}'
        ui:field='itemTable' />

Wonderful!

Finally the answer !
I tried this even simplier using UIBinder by adding :

.edit-cell input {
    width: 30px;
    text-align: right;
}

Then for the cell table I added

 <c:CellTable
        addStyleNames='{style.edit-cell}'
        ui:field='itemTable' />

Wonderful !

给我一枪 2024-12-27 23:34:32

您需要创建一个自定义组件。开箱即用的 EditTextCell 不允许您设置输入字段的大小属性,只能设置列宽。

在这里查看 ValidateableInputCell impl: GWT 验证示例...你在哪里? 获取如何制作自定义单元的示例。

诚然,验证尚未起作用,但在单元格内的输入字段上设置大小的功能可以起作用。

You'll need to create a custom component. The out of the box EditTextCell does not allow you to set the size attribute of the input field, just the column width.

Have a look at the ValidateableInputCell impl here: In search of a GWT validation example... where art thou? for an example of how to craft a custom cell.

Admittedly the validation does not yet work but the ability to set the size on the input field within the cell does.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文