GWT EditTextCell:如何增加EditTextCell中可编辑文本框的宽度?
我在我的项目中使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在我的项目中我这样做:
In my project I do that:
终于有答案了!
我使用 UIBinder 尝试了更简单的操作,添加了:
然后对于单元格表,我添加了
Wonderful!
Finally the answer !
I tried this even simplier using UIBinder by adding :
Then for the cell table I added
Wonderful !
您需要创建一个自定义组件。开箱即用的 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.