调整 Ext.form.ComboBox 的大小以适合其内容
Ext 论坛上的解决方案很少,但我无法让其中任何一个起作用。看来我错过了一些小事。
我需要在首次创建组合框时调整其大小以适应其内容。当内容发生变化时,我不需要担心调整它的大小。
有使用 Extjs 3.2 的工作示例吗?
当前代码:
var store = new Ext.data.ArrayStore({
fields: ['view', 'value', 'defaultselect'],
data: Ext.configdata.dataCP
});
comboCPU = new Ext.form.ComboBox({
tpl: '<tpl for="."><div class="x-combo-list-item"><b>{view}</b><br /></div></tpl>',
store: store,
displayField: 'view',
width: 600,
typeAhead: true,
forceSelection: true,
mode: 'local',
triggerAction: 'all',
editable: false,
emptyText: 'empty text',
selectOnFocus: true,
listeners: { select: AdjustPrice, change: AdjustPrice, beforeselect: function (combo, record, index) { return ('false' == record.data.disabled); } },
applyTo: 'confelement'
});
我还尝试删除 width: 600 并将其替换为 minListWidth: 600 但结果如下并没有解决问题。 替代文本 http://img28.imageshack.us/img28/7665/4272010105134am.png< /a>
There are quite few solutions on Ext forums, but I wasn’t able to get any of them work. It seems I am missing something minor.
I need to resize combobox to fit its content when it’s first created. I do not need to worry about resizing it when content is changing.
Is there any working examples using Extjs 3.2?
Current Code:
var store = new Ext.data.ArrayStore({
fields: ['view', 'value', 'defaultselect'],
data: Ext.configdata.dataCP
});
comboCPU = new Ext.form.ComboBox({
tpl: '<tpl for="."><div class="x-combo-list-item"><b>{view}</b><br /></div></tpl>',
store: store,
displayField: 'view',
width: 600,
typeAhead: true,
forceSelection: true,
mode: 'local',
triggerAction: 'all',
editable: false,
emptyText: 'empty text',
selectOnFocus: true,
listeners: { select: AdjustPrice, change: AdjustPrice, beforeselect: function (combo, record, index) { return ('false' == record.data.disabled); } },
applyTo: 'confelement'
});
I've also tried removing width: 600 and replacing it with minListWidth: 600 but that result following and didnt fix the issue.
alt text http://img28.imageshack.us/img28/7665/4272010105134am.png
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试以下操作:
下面的代码适用于 ExtJs 3.2!
Try the following:
Below codes works in ExtJs 3.2!
尝试
autoWidth: true
并删除宽度参数
try
autoWidth: true
and remove the width parameter
width: 600
是正确的,因此您肯定还存在其他问题,而这些问题从您发布的内容来看并不明显。您可以尝试删除applyTo
配置,而是放置renderTo: Ext.getBody()
只是为了看看它是否与它如何应用于您的元素有关。您确定没有其他代码可能会影响宽度吗?width: 600
is correct, so you must have some other issue going on that's not obvious from what you posted. You might try removing theapplyTo
config and instead putrenderTo: Ext.getBody()
just to see if it has something to do with how it's applied to your element. Are you sure there is not some other code that could be affecting the width?找到此处:
Found here: