Javascript 更改窗体面板中的按钮位置
我有一个带3个按钮的formPanel(Javascript 更改窗体面板中的按钮位置,javascript,extjs,extjs5,Javascript,Extjs,Extjs5,我有一个带3个按钮的formPanel(Filtrar,Limpiar和Nuevo Borrador)。我试图在一行中显示两个按钮(Filtrar和Limpiar),并在该按钮下显示Nuevo Borrador按钮 大概是这样的: 这是formPanel的代码 formPanel = new Ext.form.FormPanel({ id:'formulario', title: '<bean:message key="label.gi.puesto
Filtrar
,Limpiar
和Nuevo Borrador
)。我试图在一行中显示两个按钮(Filtrar
和Limpiar
),并在该按钮下显示Nuevo Borrador
按钮
大概是这样的:
这是formPanel的代码
formPanel = new Ext.form.FormPanel({
id:'formulario',
title: '<bean:message key="label.gi.puestosTipo.criteriosBusqueda" />'
,region: 'west'
,width: 300
,height: 500
,collapsible : true
,labelWidth: 77
,bodyStyle:'padding:5px 0px 0px 3px;'
,autoHeight: true
,method: 'POST'
,params: {"method": "buscarInformes"} // Buscar informe. TODO
,frame:true
,style: 'text-align: left;'
,defaultType: 'textfield'
,buttonAlign: 'center'
,items: [{
xtype: 'fieldset',
title: '<b>Datos del documento</b>',
columnWidth: 0.5,
collapsible: false,
defaultType: 'textfield',
defaults: {
anchor: '100%'
},
layout: 'anchor',
items: [{
xtype: 'combo',
fieldLabel: 'Tipo documento ',
emptyText: 'Tipo',
hiddenName: 'tipo',
store: new Ext.data.SimpleStore({
data: [
[0, 'Borrador'],
[1, 'Final'],
],
id: 0,
fields: ['value', 'text']
}),
valueField: 'value',
displayField: 'text',
triggerAction: 'all',
editable: false
},{
fieldLabel: '<bean:message key="label.analisisGestionRiesgo.salvaguardas.codigo" />',
name: 'codigo',
},{
fieldLabel: '<bean:message key="label.agr.denominacion" />',
name: 'denominacion',
}
]},{
xtype: 'fieldset',
title: '<b>Rango de fecha<b>',
columnWidth: 0.5,
collapsible: true,
defaultType: 'textfield',
defaults: {
anchor: '100%'
},
layout: 'anchor',
items: [
{
xtype: 'datefield',
fieldLabel: 'Desde',
name: 'fechaDesde',
},{
xtype: 'datefield',
fieldLabel: 'Hasta',
name: 'fechaHasta',
}]
},{
xtype: 'button',
text: '<b>Limpiar<b>',
style: 'margin: 0 1 0 1 ;'
},{
xtype: 'button',
text: '<b>Enviar<b>',
style: 'margin: 0 1 0 1 ;'
},{
xtype: 'button',
text: '<b>Nuevo borrador<b>',
style: 'margin: 0 1 0 1 ;'
}
]
}
formPanel=新建Ext.form.formPanel({
id:“公式化”,
标题:“”
,地区:'西部'
,宽:300
,身高:500
,可折叠:正确
,标签宽度:77
,车身样式:'padding:5px 0px 0px 3px;'
,自动高度:true
,方法:'POST'
,参数:{“方法”:“buscarnformes”}//Buscar informe.TODO
,帧:true
,样式:“文本对齐:左;”
,defaultType:'textfield'
,buttonAlign:'中间'
,项目:[{
xtype:“字段集”,
标题:“Datos del documento”,
列宽:0.5,
可折叠:错误,
defaultType:'textfield',
默认值:{
主持人:“100%”
},
布局:“锚定”,
项目:[{
xtype:'组合',
字段标签:“Tipo文档”,
emptyText:“Tipo”,
hiddenName:“tipo”,
存储:新Ext.data.SimpleStore({
数据:[
[0,'Borrador'],
[1,‘最终’],
],
id:0,
字段:['value','text']
}),
valueField:'值',
显示字段:“文本”,
触发动作:“全部”,
可编辑:false
},{
字段标签:“”,
名称:“codigo”,
},{
字段标签:“”,
名称:“denominacion”,
}
]},{
xtype:“字段集”,
标题:“Rango de fecha”,
列宽:0.5,
可折叠的:是的,
defaultType:'textfield',
默认值:{
主持人:“100%”
},
布局:“锚定”,
项目:[
{
xtype:'日期字段',
字段标签:“Desde”,
名称:“fechaDesde”,
},{
xtype:'日期字段',
fieldLabel:“Hasta”,
姓名:'费查哈斯塔',
}]
},{
xtype:'按钮',
文字:“Limpiar”,
样式:“边距:0 1 0 1;”
},{
xtype:'按钮',
文本:“Enviar”,
样式:“边距:0 1 0 1;”
},{
xtype:'按钮',
文字:“新博拉多”,
样式:“边距:0 1 0 1;”
}
]
}
我也尝试使用
alignTarget:“center”
将按钮居中(在xtype:“button”
元素中)和buttonAlign:'center'
,正如我在ext docs中看到的那样,但不起作用。我需要使用什么方法在中心显示我的按钮?提前感谢。将按钮放在一个单独的容器中,然后您可以在其上设置所需的任何布局。例如:
Ext.create('Ext.form.FormPanel', {
items: [
{ xtype: 'fieldset', title: 'Datos del documento', items: [] },
{ xtype: 'fieldset', title: 'Rango de fecha', items: [] },
{
xtype: 'container',
defaultType: 'button',
items: [
{ text: 'Limpiar' },
{ text: 'Enviar' },
{ text: 'Nuevo borrador' }
],
// Use any layout here.
layout: {
type: 'vbox',
pack: 'center'
}
}
]
});
您甚至可以使用绝对布局来获得完美的定位。哪个版本的Ext?谢谢!使用容器/布局,我可以毫无问题地放置按钮。