【发布时间】:2015-03-03 13:05:22
【问题描述】:
我有一个类似这个话题的问题:Extjs how to make the scrollbar appear?,但是太多的事情让我感到困惑。
只要表单比包含容器宽,我就需要显示滚动条。为什么 autoScroll: true 不起作用?
我将结合这个问题给出三个不同的例子。最需要的- 第一个前任。 1.https://fiddle.sencha.com/#fiddle/j2c
var win = Ext.create("Ext.window.Window", {
renderTo: Ext.getBody(),
title: "Window",
bodyPadding: 5,
layout: 'anchor',
items: [{
itemId: "TPMethodContentProvider",
xtype: "form",
autoScroll: true,
layout: 'anchor',
anchor: "100%",
items: [{
xtype: "container",
padding: 5,
layout: 'anchor',
anchor: "100%",
autoScroll: true,
items: [{
margin: 5,
padding: 5,
width: 850,
xtype: "container",
autoScroll: true,
anchor: "100%",
layout: 'column',
items: [{
columnWidth: 0.7,
items: [{
itemId: "S1",
margin: 5,
xtype: 'textfield',
anchor: "95%",
fieldLabel: "type:",
labelWidth: 140,
tabIndex: 0,
value: "bd",
}],
layout: "anchor"
}, {
columnWidth: 0.3,
items: [{
itemId: "S2",
margin: 5,
xtype: 'textfield',
anchor: "95%",
fieldLabel: "num:",
labelWidth: 140,
}],
layout: "anchor"
}, ] //panel items
}] // some container items
}] // form items
}] }); win.show();
没有滚动条。
-
..fiddle.sencha.com/#fiddle/j2f
Ext.create('Ext.form.Panel', { renderTo: Ext.getBody(), title: 'Form Panel', bodyPadding: '5 5 0', width: 600, items: [{ xtype: 'container', padding: '5', layout: 'anchor', fieldDefaults: { labelAlign: 'top', msgTarget: 'side' }, defaults: { border: false, xtype: 'panel', layout: 'anchor' }, layout: 'hbox', items: [{ items: [{ xtype:'textfield', fieldLabel: 'First Name', anchor: '-5', name: 'first', }] }, { items: [{ xtype:'textfield', fieldLabel: 'Last Name', anchor: '100%', name: 'last' }] }], }], }); //Ext.create('Ext.container.Viewport', {});
它有效,直到最后一行注释 Ext.create('Ext.container.Viewport', {}); 如果我删除项目 Viewport 中的代码,则会观察到相同的行为。
-
..fiddle.sencha.com/#fiddle/j2g..
Ext.create('Ext.container.Viewport', { padding: '5', items: [{ id: 'mainPanelContainer', autoScroll: true, xtype: 'container', padding: '5', layout: 'anchor', //width: 600, items: [{ //outer container autoScroll: true, xtype: 'container', padding: '5', layout: 'anchor', width: 600, items: [{ xtype: 'container', padding: '5', layout: 'column', items: [{ xtype: 'textfield', fieldLabel: 'text1', name: 'Name1', columnWidth: .3 }, { xtype: 'textfield', fieldLabel: 'text2', name: 'Name2', columnWidth: .7 }], //container items }], //outer container items }, ] //form items }, ]});
滚动一直有效,直到在那个地方设置了宽度:600,但在注释的地方不起作用。
抱歉,2、3 ex 中的外部代码。一些不方便的 sn-ps 代码。
【问题讨论】:
标签: extjs