How to place button just after textfield - extjs

I am using a Fieldset of extjs which have text, buttons and dropdown using extjs.
my code for fieldset is as follow
ds=Ext.create('Ext.form.FieldSet', {
title: 'System Input',
width:500,
style: {
marginLeft: '5px',
marginTop:'10px'
},
labelWidth: 75,
items :[{xtype: 'displayfield', value: 'Modify the inputs below to run another simulation'},roofarea,clss,roofslider,pvtech,rate,pvsyssize,systypebuild,elecrate,tiltang,scclsbtn,scclsbtncls]
});
now i have text field(i.e. roofarea) and button(i.e.clss) in this fieldset, i want button just after text field just beside, my code for this is as follow but button come just below text field:
roofarea = Ext.create('Ext.form.field.Text', {
width: 300,
autoScroll :true,
labelWidth: 160,
style: {
marginLeft:'10px',
marginTop: '10px',
marginBottom:'10px'
},
fieldLabel: 'Total Roof Area(Sq. Meter):',
readOnly: true,
value:faread
});
var clss =Ext.create('Ext.Button', {
text: 'Close',
width:15,
handler: function() {
smWindow.hide();
}
});
but other items should be down of text field and button.
Please help me for this?

It is just a matter of layout. I added both text field and button in a hbox layout and this fieldset (closeFieldSet), I added to your ds.
Below is the code snippet :
roofarea = Ext.create('Ext.form.field.Text', {
width: 300,
autoScroll: true,
labelWidth: 160,
style: {
marginLeft: '10px',
marginTop: '10px',
marginBottom:'10px'
},
fieldLabel: 'Total Roof Area(Sq. Meter):',
readOnly: true,
value: 20
});
var clss = Ext.create('Ext.Button', {
text: 'X',
width: 50,
style: {
marginTop: '10px'
},
handler: function() {
smWindow.hide();
}
});
var closeFieldSet = Ext.create('Ext.form.FieldSet', {
title: 'System ',
layout: 'hbox',
width: 500,
labelWidth: 75,
items: [roofarea,clss]
});
var ds = Ext.create('Ext.form.FieldSet', {
title: 'System Input',
width:500,
style: {
marginLeft: '5px',
marginTop:'10px'
},
labelWidth: 75,
// items: [{xtype: 'displayfield', value: 'Modify the inputs below to run another simulation'},roofarea,clss,roofslider,pvtech,rate,pvsyssize,systypebuild,elecrate,tiltang,scclsbtn,scclsbtncls]
items: [
closeFieldSet,
{
xtype: 'displayfield',
value: 'Modify the inputs below to run another simulation'
}
]
});

Have a look at this links.. Hope this helps you
http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.ComboBox
http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.CompositeField

sample code here
this.form= new Ext.FormPanel({
title:'New Developer',
renderTo: 'frame',
defaults:{xtype:'textfield'},
bodyStyle:'padding: 10px',
items:[
name,
{
fieldLabel:'Email',
name:'txt-email',
value:'default#quizzpot.com',
id:"id-email"
},{
xtype: 'checkbox',
fieldLabel: 'Active',
name: 'chk-active',
id: 'id-active'
},
{
xtype:'hidden',
name:'h-type',
value:'developer'
}
],
buttons:[{text:'Save'},{text:'Cancel'}] //<-- button of the form
});

Related

How to open a Panel on Button click

I want to open a panel window under the button i click which is located in the header. The panel should be displayed under the button (aligned with the header) : i try :
{
xtype:'button',
height: '100%',
text: Strings.Notifications,
glyph: 'xf142#FontAwesome',
reference: 'settingsNotificationsButton',
cls :'headerButtonsCls',
listeners: {
click: function () {
new Ext.form.Panel({
width: 200,
height: 200,
title: 'Foo',
floating: true,
closable: false
}).show();
}
}
}
But the above code displays the panel in middle of the screen as a modal which i don't want (as i said i want it right under the header)
So how to achieve that ?
Thanks .
I took Muzaffers answer as base and added the feature to use the event coordinates here:
var windowPanel = Ext.create('Ext.Panel', {
bodyStyle: 'background: #ffff00;',
border: true,
height: 200,
width: 200,
floating:true
});
Ext.create('Ext.Container', {
renderTo: Ext.getBody(),
items: [{
xtype: 'button',
text: 'Show/Hide Panel',
handler: function (btn, event) {
windowPanel.showAt(event.getXY())
}
}
]
});
Here is the fiddle: https://fiddle.sencha.com/#fiddle/3a8j&view/editor
Is that useful for you?
var windowPanel = Ext.create('Ext.Panel', {
bodyStyle: 'background: #ffff00;',
border: true,
height: 200,
width: 200,
hidden: true
});
Ext.create('Ext.Container', {
renderTo: Ext.getBody(),
items: [{
xtype: 'button',
text: 'Show/Hide Panel',
handler: function () {
if (windowPanel.isHidden()) {
windowPanel.show();
} else {
windowPanel.hide();
}
}
},
windowPanel
]
});
https://fiddle.sencha.com/#fiddle/3a8c

ExtJS panel layout with sub panels and donut chart

I am trying to achieve a layout similar to the below where a panel contains 2 boxes to the left and a donut chart (contained within it's own panel) to the right.
Clicking on either box on the left would trigger a reload of the chart.
I am unclear what elements would be best for the clickable boxes to the left and also how i could align them with the chart. Would a container make it easier to position the elements as required ?
Thanks for any assistance.
to achieve the layout you want, there are several ways. The most popular are border layout and combination v hbox and vbox layout.
I will show both.
for click listener you can use container too if button is not an option, listener implementations are in examples too.
border layout mosly are used for main panels.
this is border layout example, here is fiddle
Ext.create('Ext.panel.Panel', {
renderTo: Ext.getBody(),
title: "Main Panel",
width: "100%",
bodyPadding: 5,
height: Ext.getBody().getHeight(),
layout: "border",
items: [{
xtype: "panel",
title: "leftContainer",
region: "west",
width: 300,
layout: {
type: 'vbox',
align: 'stretch'
},
items: [{
type: "conatiner",
style: "border:1px solid red",
html: "first container",
flex: 1,
listeners: {
el: {
click: function () {
alert("first Container")
}
}
}
}, {
type: "conatiner",
style: "border:1px solid red",
html: "secon container",
flex: 1,
listeners: {
el: {
click: function () {
alert("second Container")
}
}
}
}]
}, {
xtype: "panel",
margin: "0 0 0 5",
title: "center Container",
region: "center"
}]
})
and this second example achived with layout hbox, here is fiddle
Ext.create('Ext.panel.Panel', {
renderTo: Ext.getBody(),
title: "Main Panel",
width: "100%",
bodyPadding: 5,
height: Ext.getBody().getHeight(),
layout: {
type: 'hbox',
align: 'stretch'
},
items: [{
xtype: "panel",
title: "leftContainer",
width: 300,
layout: {
type: 'vbox',
align: 'stretch'
},
items: [{
type: "conatiner",
style: "border:1px solid red",
html: "first container",
flex: 1,
listeners: {
el: {
click: function () {
alert("first Container")
}
}
}
}, {
type: "conatiner",
style: "border:1px solid red",
html: "secon container",
flex: 1,
listeners: {
el: {
click: function () {
alert("second Container")
}
}
}
}]
}, {
xtype: "panel",
margin: "0 0 0 5",
title: "center Container",
flex: 1
}]
})

Ext JS 6.0.0 Button margin property not work

I have a button in a panel, and I need set a margin value, but the component not apply the value of margin, the EXT just ignore the margin property.
The follow code:
Ext.define('CadastroEnsaioWTD.view.typecalculated.TypeCalculatedItem', {
extend: 'Maestro.panel.Panel',
requires: [
'Maestro.form.Button',
'Maestro.form.TextField',
'Maestro.form.ComboBox'
],
alias: 'widget.typecalculateditemview',
layout: {
type: 'hbox',
align: 'middle'
},
width: '100%',
height: '100%',
initComponent: function () {
var me = this;
var config = {
defaults: {
width: 200,
node: me.node,
margin: '5 5 5 5',
labelSeparator: '',
xtype: 'maestro.form.textfield'
},
items: [
{
xtype: 'label',
html: '<b>' + me.alias + '</b>',
width: 100
},
{
width: 300,
xtype: 'maestro.form.combobox',
name: 'ENS_TIPO_DETERMINADO_CARACT'
},
{
xtype: 'maestro.form.combobox',
name: 'ENS_ENR_REFRIGERACAO_WTD'
},
{
name: 'ENS_PERC_CARGA_WTD'
},
{
name: 'ENS_COS_PHI'
},
{
width: 170,
xtype: 'maestro.form.combobox',
name: 'ENS_TIPO_ENR_APL_WTD'
},
{
width: 170,
xtype: 'maestro.form.combobox',
name: 'ENS_TIPO_ENR_CC_WTD'
},
{
name: 'ENS_ENR_TAP_TENSAO_APL'
},
{
name: 'ENS_ENR_TAP_TENSAO_CC'
},
{
name: 'ENS_POT_REF_WTD'
},
{
name: 'ENS_PERC_TENSAO_WTD'
},
{
width: 100,
name: 'ENS_TIPO_DETERMINADO_VAL'
},
{
width: 100,
xtype: 'maestro.form.combobox',
name: 'ENS_TIPO_DETERMINADO_UNID'
},
{
xtype: 'button',
text: '-',
width: 30,
style: 'border-radius: 7px;',
handler: function (btn) {
me.getObjectContextSynchronizer().executeServerRequest('deleteContextNode', [me.node]);
}
}
]
};
Ext.apply(this, config);
this.callParent();
}
});
And if I set the value by console of chrome after the component rendered, using Ext.getCmp('xxxx').setMargin('15 0 0 0') does not work, but if I use Ext.getCmp('xxxx').getEl().setMargin('15 0 0 0') works.
Did I do something wrong?
you should use style:'margin:5px;' instead of using margin property
You do it properly. I created working fiddle for you with button margins - Button & margin.
Try to play with it and repeat your issue.

How can i include two textboxes in Ext.Msg.show

How can I modify the Ext.Msg.show in sencha to show two text boxes.Right now it supports only one textbox when we set prompt:true
Ext.Msg.show({
title: 'Enter values',
width: 500,
buttons: Ext.Msg.OKCANCEL,
multiline: true,
prompt:true,
});
The easiest solution is just create a window. Like Evan said in the comment, the MessageBox is just an Ext.window.Window width a little extra..
a working fiddle
Here's a example definition:
Ext.define('MyApp.view.Login', {
extend: 'Ext.window.Window',
height: 220,
width: 490,
layout: 'fit',
modal: true,
buttonAlign: 'left',
closable: false,
items: [
{
xtype: 'form',
frame: false,
border: 0,
layout: {
type: 'hbox',
align: 'middle'
},
fieldDefaults: {
msgTarget: 'side',
labelWidth: 55
},
items: [
{
xtype: 'container',
flex: 1,
padding: 10,
layout: {
type: 'vbox',
align: 'stretch'
},
items: [
{
xtype: 'textfield',
name: 'username',
fieldLabel: 'Username',
allowBlank: false,
flex: 1
},
{
xtype: 'textfield',
name: 'password',
fieldLabel: 'Password',
inputType: 'password',
allowBlank: false,
flex: 1
}
]
}
]
}
],
buttons: [
{
text: 'Login',
handler: function () {
Ext.Msg.alert('This is not yet implemented.').show();
}
}
]
});
Then you can just create and show the window:
Ext.create('MyApp.view.Login').show();
The msg property of the Ext.MessageBox will render as HTML, so you can tell it to show two HTML inputs and then use the values from these using something like
Ext.Msg.show(
{
title: 'Enter values:',
width: 500,
buttons: Ext.Msg.OKCANCEL,
msg: 'Value1: <input type="text" id="textInput1" /><br />Value 2: <input type="text" id="textInput2" />',
fn: function (button)
{
var value1 = document.getElementById('textInput1').value;
var value2 = document.getElementById('textInput2').value;
}
});
Although, depending on what you're trying to do, using a window as suggested may be a better solution

autoscroll does not work with vbox layout

I need align the formpanels to the center, so I used the vbox layout, and after I used it the autoscroll did not work as before, the code is as below:
Usr.VWPanel = Ext.extend(Ext.Panel, {
id: null,
rid: null,
closable: true,
autoScroll: true,
buttonAlign: 'center',
layout: {
type:'vbox',
padding:'5',
pack:'center',
align:'center'
},
initComponent: function () {
Ext.apply(this, {
items: [
{
xtype: 'spacer',
height: 16
},
{
xtype: 'usr.usrform',
itemId: 'usr.vwpain.usrformt',
width: 600,
height: 500
},
{
xtype:'spacer',
height: 16
},
{
xtype: 'usr.loginform',
itemId: 'usr.vwpain.loginform',
width: 600
},
{
xtype: 'spacer',
height: 16
},
{
xtype: 'usr.subsform',
itemId: 'usr.vwpain.subsform',
width: 600
}],
...
plz advise.
the vbox layout will never show the scroller.
{
xtype: 'window',
title: 'My Window',
width: 500,
height: 500,
layout: 'vbox',
layoutConfig: {
pack: 'center',
align: 'center'
},
items: [
{
xtype: 'panel',
title: 'My Panel',
anchor: '80% 100%',
height: 300,
width: 300,
autoScroll: true,
items: [
{
xtype: 'panel',
html: 'this isform1',
height: 100
},
{
xtype: 'panel',
html: 'this isform1',
height: 100
},
{
xtype: 'panel',
html: 'this isform1',
height: 100
}
]
}
]
}
in your css you can set your My Panel margins to {0 auto} which will center the My Panel inside the window. This means you don't need a special layout config for your window.
I have added a listener on resize event to get the vertical scroll as for Vbox we have to provide height to get scroll but when window size get change scroller height remain constant.
Ext.define('DataConfigurations', {
extend: 'Ext.form.Panel',
bodyStyle: 'padding:5px 5px;',
listeners: {
resize: {
fn: function(el) {
this.setHeight(this.up('window').getHeight()-150); // 150 is extra for my panel coz of headers so have minus it.
console.log("new height = " + this.up('window').getHeight()-150);
}
}
},
title: "Update Data Configurations",
Hopes this help.

Resources