Extjs - Dock Button to bottom of the Panel - javascript

I want to align Credentials button to the bottom of the panel in extjs, Is there any specific property to do that only for buttons inside the panel. No toolbar involvement is here:
Fiddle Link : https://jsfiddle.net/arya9/rmad2cpb/

Check this fiddle.
You just need to add that button in dockedItems of Panel
{
xtype: 'panel',
renderTo: Ext.getBody(),
layout: 'vbox',
height: 400,
padding: 20,
defaults: {
xtype: 'button',
margin: '0 0 12 0'
},
items: [{
text: 'Normal Button'
}, {
text: 'Basic Button'
}],
dockedItems: [{
xtype: 'button',
dock: 'bottom',
text: 'Docked Button',
margin: '0 0 12 0'
}]
}
https://fiddle.sencha.com/#view/editor&fiddle/25aa

Hope this below code will help you as per your requirement.
Ext.create('Ext.Window',{
width:200,
height:400,
layout:'vbox',
items:[{
xtype:'button',
text:'First'
},{
xtype:'panel',
flex:1
},{
xtype:'button',
text:'Second'
}]
}).show();
You can check here in sencha fiddle it is working https://fiddle.sencha.com/#view/editor&fiddle/25a9

Use a toolbar and change xtype: 'spacer' for xtype: 'tbfill'

Related

ExtJs - Dynamically changing expand and collapse buttons of panel

I have a docked panel in which am changing the dock position using the setDock method. In that docked panel, I also have collapsible buttons which should change as per to the dock position. I am updating the configs collapseDirection and expandDirection and calling out a method updateCollapseTool which lets me update the button.
But I get an issue after the following steps:
Change the dock position to left using the menu button.
Collapse the docked panel using the collapse button, then again expand it.
Again change the dock position to top.
Collapse the docked panel again => After this step my docked panel gets collapsed, but it seems to be collapsed in left direction. It should have collapsed to top and should show an expand button pointing in bottom direction.
If I perform the same steps by excluding the step 2, it works properly. Is there anything that am doing wrong or any other methods which lets me update my expand/collapse buttons properly ?
Here is my fiddle link.
You can use border layout and the the region with setRegion method, something like this:
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.create({
scrollable: true,
id: 'parentPanel',
xtype: 'panel',
height: 500,
layout: 'border',
items: [{
xtype: 'panel',
id: 'dockPanel1',
region: 'north',
title: 'Parent Dock Panel',
collapsible: true,
collapseFirst: false,
width: 300,
height: 200,
defaults: {
style: {
background: "orange",
border: "1px"
},
},
layout: "container",
tools: [{
text: "dock change",
xtype: 'button',
value: 'top',
menu: {
items: [{
text: 'top',
region: 'north'
}, {
text: 'left',
region: 'west'
}, {
text: 'right',
region: 'east'
}],
listeners: {
click: function (menu, item, e, eOpts) {
Ext.getCmp('dockPanel1').setRegion(item.region);
}
}
}
}],
items: [{
xtype: 'textfield',
text: 'item 1'
}, {
xtype: 'textfield',
text: 'item 2'
}, {
xtype: 'textfield',
text: 'item 3'
}]
}, {
xtype: 'panel',
region: 'center',
layout: "vbox",
items: [{
html: "<span style='font-size:20px;'>Child panel 1</span>",
bodyStyle: "background: lightgreen;",
xtype: 'panel',
height: "50%",
width: "70%",
padding: "5 5",
cls: 'overlayMenuCls'
}, {
html: "<span style='font-size:20px;'>Child panel 2</span>",
bodyStyle: "background: lightblue;",
xtype: 'panel',
height: "50%",
width: "70%",
padding: "5 5",
cls: 'overlayMenuCls'
}]
}],
renderTo: Ext.getBody()
});
}
});

vbox layout is not working in border layout

I have a requirment where i need to put one item inside vbox layout. my item is having a border layout and west and center reason having some vbox layout componet. below I am putting the code of item. In this main panel is border layout and reason having vbox but this is not working.
my Code :
Ext.create('Ext.panel.Panel', {
width: 500,
height: 500,
title: 'Border Layout',
layout: 'border',
items: [{
title: 'South Region is resizable',
region: 'south', // position for region
xtype: 'panel',
height: 100,
layout : 'fit',
split: true,// enable resizing
margin: '0 5 5 5'
},{
// xtype: 'panel' implied by default
title: 'West Region is collapsible',
region:'west',
xtype: 'panel',
margin: '5 0 0 5',
width: 100,
layout: 'vbox',
height: 200,
items:[{
title: 'South Region is resizable',
xtype: 'panel',
height: 100
},{
title: 'ss Region is resizable2',
xtype: 'panel',
height: 100
}],
collapsible: true, // make collapsible
id: 'west-region-container',
},{
title: 'Center Region',
region: 'center', // center region is required, no width/height specified
xtype: 'panel',
width : 300,
layout: 'vbox',
margin: '5 5 0 0',
items:[{
title: 'South Region is resizable',
xtype: 'panel',
height: 50,
},
{
title: 'ss Region is resizable',
xtype: 'panel',
height: 10
}]
}],
renderTo: Ext.getBody()
});
Below is my Actual code where I am using vboxLayout and then border layout is one of the item of this. I am getting Layout run failed error
Ext.define('myApp.myData.myApp', {
extend: 'Ext.container.Container',
alias: 'widget.myApp',
controller: 'myAppController',
items: [{
xtype: 'label',
margin: '5 10 0 0',
height: 28
},
{
xtype: 'panel',
itemId: 'mainPanel',
layout: {
type: 'vbox',
align: 'stretch'
},
defaults: {
margin: '3 10 2 5'
},
items: [
{
xtype: 'myPanel'
},{
xtype : 'panel',
height: 500,
width : 300,
layout: 'border',
items :[{
xtype : 'panel',
layout: {
type: 'vbox',
align: "stretch"
},
items :[{
xtype: 'myPanel1'
},{
xtype : 'myPanel2'
}]
},{
xtype : 'panel',
layout: {
type: "vbox",
align: "stretch"
},
items :[{
xtype: 'myGrid'
}]
}]
}
]
}]
});
Any help will appriciate.
Change your layout to:
layout: {
type: "vbox",
align: "stretch"
}
And put flex on child items:
flex: 1

ExtJS how to reference region panel in viewport

Hi I have a problem about extjs viewport. I created a button and tried to reference to east panel but It seems a wrong way to access panel. Chrome developer tools showed a message "Uncaught TypeError: Cannot read property 'get' of undefined"
I google this thread
but my code is still not work.
my viewport:
var viewport = Ext.define('Fiddle.view.Viewport', {
extend: 'Ext.container.Viewport',
layout: 'border',
items: [{
// xtype: 'container',
// itemId: 'header',
region: 'north',
//html: '<h1 class="x-panel-header">Page Title</h1>',
border: false,
margin: '0 0 5 0',
items: [{
xtype: 'button',
text: 'collapse',
handler: function() {
var east = viewport.items.get('e');
if (!!east.collapsed) {
east.expand();
} else {
east.collapse();
}
}
}]
}, {
region: 'east',
title: 'east Panel',
itemId: 'e',
//collapsible: true,
//collapseMode: 'mini',
floatable: false,
html: 'Information goes here',
split: true,
placeholder:{
width:20,
items:[{
xtype:'button',
}]
}
}, {
region: 'center',
xtype: 'container',
layout: 'fit',
items: {
html: 'Center'
}
}]
})
Fiddle
Instead of viewport.items.get('e'), use down:
viewport.down('#e')
Update:
In your code sample, viewport is referencing the viewport class, not instance. To access the instance from the button clicked, use:
b.up('viewport').down('#e')
Full example: https://fiddle.sencha.com/#fiddle/rl2
Avoid using itemId's. Doesn't
b.up('viewport').down('container[region=east]');
do the trick?

How do I center a button on a table and have that table fill a container in ExtJS?

I am new to ExtJS and I am having trouble centering a button in a container. I am basing my code off of the documentation on the Sencha website; however, I don't see a clear explanation for centering. below is what I have so far:
items: [{
html: content,
title: 'Navigation',
autoScroll: true,
border: false,
iconCls: 'nav'
}, {
title: 'Other',
border: false,
autoScroll: true,
iconCls: 'settings',
items: [{
xtype: 'container',
layout: {
type: 'table',
columns: 1,
tdAttrs: {
style: {
layout: 'fit',
padding: '5px 10px',
background: 'red'
}
}
},
items: [{
xtype: 'button',
width: '100%',
glyph: 72,
text: 'Logoff',
scale: 'large',
iconAlign: 'top',
buttonAlign: 'center'
}]
}]
}]
Here's a screenshot of my current website.
As you can see, it is left aligned and no matter what I try, I can't seem to center it in the column.
There is a user extension for centered layout, but you can also achieve it with the following vbox layout config:
layout: {
align: 'center',
pack: 'center',
type: 'vbox'
}
Sometimes css overide itself, for be very basic but quick just add somes
Inline and before your element. It's just the html code of a blank character..
You can add you own CSS class to button using cls property, like below
items: [{
xtype: 'button',
width: '100%',
glyph: 72,
text: 'Logoff',
scale: 'large',
iconAlign: 'top',
buttonAlign: 'center',
cls: 'yourclassName'
}]
Then define CSS class yourClassName
Hope this helps

Reset does not work a form in Sencha Touch

All I want to do is when I click the reset button on my form it resets all fields. And I have tried everything but it does not seem to work. Here is the class that has the button in it:
App.views.HomeIndex = Ext.extend(Ext.form.FormPanel,{
floating: true,
scroll: 'vertical',
itemId: 'jobSearch',
centered: true,
modal: true,
hideOnMaskTap: false,
items: [{
xtype: 'textfield',
itemId: 'keywords',
label: 'Keywords',
labelAlign: 'top',
labelWidth: '100%',
name: 'keywords'
},{
xtype: 'textfield',
label: 'Job Title',
itemId: 'jtitle',
labelAlign: 'top',
labelWidth: '100%',
name: 'jtitle'
},{
.... //more xtypes here
,
dockedItems: [{
xtype: 'toolbar',
itemId: 'toolbar',
dock: 'bottom',
height: '36',
items: [
{ xtype: 'button', text: 'Reset',itemId: 'resetBtn',
},
{ xtype: 'spacer'},
{ xtype: 'button', text: 'Submit',itemId:'submitBtn',ui: 'action',
}
]
}]
In my App.js I have the code to handle the reset method:
//this is one way I thought of doing it. But obviously it does not work. I have tried googling all over but couldnt find a solution.
this.homeView.query('#resetBtn')[0].setHandler(function(){
var form = this.el.up('.x-panel');
//form.down('.x-input-text[name=keywords]').setValue(' ');
form.query('#jobSearch').getComponent('keywords').reset();
});
});
Ext.reg('HomeIndex', App.views.HomeIndex);
Your form's ID is "jobSearch", the name is "keyboards". You're trying to combine both.
Try:
form.query('#jobSearch').reset();
or:
document.forms['keywords'].reset();
Try this. It's a bit more ExtJS like.
var form = Ext.ComponentQuery.query('#jobSearch .form')[0];
form.reset();

Categories