我正在使用编辑器进行内联编辑树节点值,当大文本的位置发生变化时?以下是我为测试此场景而编写的代码。
var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [
{ text: "ong label for testing long options test field.50", leaf: true },
{ text: "long label for testing long options test field.50 long label for testing log option test field. 100", leaf: true },
{ text: "option4", leaf: true }
]
}
});
Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 300,
height: 250,
store: store,
rootVisible: false,
defaultRootId: 0,
renderTo: Ext.getBody(),
listeners: {
itemdblclick: function (View, record, item, index, e, eOpts) {
var editor = new Ext.Editor({
ignoreNoChange: true,
revertInvalid: true,
width: 235,
shadow: false,
//offsets: [-150, 0],
hideEl: false,
field: {
xtype: 'textfield',
maxLength: 500,
enforceMaxLength: true,
allowBlank: false
}
});
editor.startEdit(item, record.get('text'));
editor.on('complete', function (me, value) {
if (value.replace(/^[\s]+/, '').replace(/[\s]+$/, '').replace(/[\s]{2,}/, ' ') != "") {
record.set('text', value);
}
}, item, { single: true });
}
}
});
我用的是Extjs4.1版本