Extjs 6.5+ Adding Components to Container Gives Empty Viewport - extjs

Not sure why I'm getting an empty viewport. I am defining subclasses as components and trying to get the viewport to display the 2 components created. Seems simple enough yet coming up empty?
Ext.define('MyApp.view.MyHeader', {
extend: 'Ext.Container',
items: [{
xtype: 'titlebar',
title: 'Logo',
titleAlign: 'left',
cls: 'im-titlebar',
dock: 'top',
id: 'titlebar',
items: [
{
xtype: 'button',
text: 'Log In',
align: 'right',
ui: 'action',
margin: '',
ariaRole: 'button',
cls: 'btn-im-login action noprint',
id: 'button_LogIn'
}
]
}]
});
Ext.define('MyApp.view.MyFooter', {
extend: 'Ext.Container',
items: [{
xtype: 'container',
items: [{
xtype: 'button',
text: 'Button',
align: 'right',
ui: 'action',
ariaRole: 'button',
cls: 'btn-im-login action noprint',
id: 'button_Button'
}]
}]
});
Ext.define('MyApp.view.MyView', {
extend: 'Ext.Container',
requires: ['MyApp.view.MyHeader', 'MyApp.view.MyFooter']
});
Ext.Loader.setConfig({
enabled: false
});
Ext.application({
name: 'MyApp',
launch: function () {
Ext.Viewport.add(Ext.create('MyApp.view.MyView'));
}
});
See fiddle

You're trying to require views, but you should add it to parent view by items array.
Ext.define('MyApp.view.MyHeader', {
extend: 'Ext.Container',
xtype: 'myheader',
items: [{
xtype: 'titlebar',
title: 'Logo'
}]
});
Ext.define('MyApp.view.MyFooter', {
extend: 'Ext.Container',
xtype: 'myfooter',
items: [{
xtype: 'container',
items: [{
xtype: 'button',
text: 'Button'
}]
}]
});
Ext.define('MyApp.view.MyView', {
extend: 'Ext.Container',
xtype: 'myView',
height: 100,
items: [{
xtype: 'myheader'
}, {
xtype: 'myfooter'
}]
});
Ext.application({
name: 'MyApp',
launch: function () {
Ext.Viewport.add({
xtype: 'myView'
});
}
});
Remember - classic toolkit does not have Ext.Viewport class.
Ext.application({
name : 'MyApp',
launch : function() {
Ext.create({
xtype: 'panel',
renderTo: Ext.getBody(),
bodyPadding: 20,
tbar: {
items: [{
xtype: 'label',
text: 'Header'
}]
},
bbar: {
items: [{
xtype: 'label',
text: 'footer'
}]
},
items: [{
xtype: 'form',
title: 'My Form',
layout: 'form',
items: [{
xtype: 'textfield',
fieldLabel: 'someField'
}]
}]
});
}
});

Your code does what you have defined.
You need to add the Header and Footer components as items.
I would suggest that you may try to to use a panel and / or use tbar, bbar or header configs available there.
docs:
https://docs.sencha.com/extjs/6.2.0/classic/Ext.panel.Panel.html
https://docs.sencha.com/extjs/6.2.0/classic/Ext.panel.Panel.html#cfg-dockedItems
https://docs.sencha.com/extjs/6.2.0/classic/Ext.panel.Panel.html#cfg-header
https://docs.sencha.com/extjs/6.2.0/classic/Ext.panel.Panel.html#cfg-bbar
Ext.application({
name: 'MyApp',
launch: function () {
var f = Ext.create('MyApp.view.MyHeader', {
flex: 1
});
var h = Ext.create('MyApp.view.MyFooter', {
flex: 1
});
Ext.Viewport.add(Ext.create('MyApp.view.MyView', {
layout: {
type: 'vbox',
align: 'stretch'
},
items: [h, f]
}));
}
});

Related

Sencha touch-how should I add a tab panel inside a panel? following answer is not working it not diaplaying content inside tab panel

Ext.define('SenchaCalc.view.TabScreen',{
extend: 'Ext.tab.Panel',
xtype: 'tabScreen',
requires: [
'Ext.tab.Panel',
],
config:{
xtype:'tabpanel',
ui: 'light',
itemId: 'tabPanel',
name: 'tabPanel',
layout:
{
animation: 'fade',
type: 'card'
},
items:[
{
title: 'HOME',
iconCls: 'home',
itemId:'home',
items:[{
xtype:'panel',
itemId:'homePanel',
height:450,
width:1010,
items:[{
xtype:'button',
itemId:'homePanelButton',
name:'homePanelButton',
html:'I m in Home Panel',
height:50,
width:350,
style:'border:0px;background:#1985D0;',
cls:'homePanelButton',
}]
}]
}]
},
{
title: 'HELP',
iconCls: 'action',
itemId:'help',
items:[{
xtype:'panel',
itemId:'helpPanel',
height:450,
width:1010,
items:[{
xtype:'button',
itemId:'helpPanelButton',
name:'helpPanelButton',
html:'I m in Help Panel',
height:50,
width:350,
style:'border:0px;background:#1985D0;',
cls:'helpPanelButton',
}]
}]
}],
}
});
/******************************************************************************/
Ext.define('SenchaCalc.view.MainScreen',{
extend: 'Ext.Panel',
xtype: 'mainScreen',
requires: [
'Ext.tab.Panel',
],
config:{
xtype: 'panel',
items:[
xtype: 'tabScreen',
]
}
});
How you are handling navigation between panel and tabscreen in your MainScreen? If you have any controller paste the code. You have not mentioned any layout there. If you want to present them in different screen then please use card layout for MainScreen. For testing of nested tabpanel inside panel I have used vbox layout and pasted the code here. Please run this on sencha jsfiddle for testing.
Ext.application({
name: 'Sencha',
launch: function() {
Ext.create("Ext.Panel", {
fullscreen: true,
xtype: 'mainScreen',
layout: {
type: 'vbox'
},
requires: [
'Ext.tab.Panel',
],
items:[
{
xtype: 'panel',
flex:1,
style: 'background:red',
html:'Main screen data'
},
{
xtype: 'tabpanel',flex:1,
tabBarPosition: 'bottom',
defaults: {
styleHtmlContent: true
},
items: [
{
title: 'Page1',
iconCls: 'home',
html: 'Panel screen data page1'
},
{
title: 'Page2',
iconCls: 'user',
html: 'Panel screen data page2'
}
]
}
]
});
}
});

load grid panel into content panel

I try to understand the basics of the extjs MVC.
I created the example app with the Sencha CMD. This comes with some basic things. What i try to make is a panel with a toolbar where i have a menu. When i click on a item in the menu i want to load a grid into the panel.
What function do i need to do this?
This is my mainmodel
Ext.define('JustRent.view.main.Main', {
extend: 'Ext.container.Container',
requires: [
'JustRent.view.main.MainController',
'JustRent.view.main.MainModel',
'JustRent.view.main.ProductenType'
],
xtype: 'app-main',
controller: 'main',
viewModel: {
type: 'main'
},
layout: {
type: 'border'
},
items: [{
region: 'center',
id: 'contentBlock',
xtype: 'panel',
layout: 'fit',
title: 'JustRental',
dockedItems: [{
xtype: 'toolbar',
dock: 'top',
items: [{
xtype: 'button',
text: 'Menu',
menu: {
xtype: 'menu',
items: [{
xtype: 'menuitem',
text: 'verhuur',
menu: {
xtype: 'menu',
items: [{
xtype: 'menuitem',
text: 'Offertes',
menu: {
xtype: 'menu',
items: [{
xtype: 'menuitem',
text: 'Overzicht'
},{
xtype: 'menuitem',
text: 'Nieuwe offerte'
},{
xtype: 'menuitem',
text: 'Openstaande offertes'
},{
xtype: 'menuitem',
text: 'Geannuleerde offertes'
}]
}
}, {
xtype: 'menuitem',
text: 'Projecten',
menu: {
xtype: 'menu',
items: [{
xtype: 'menuitem',
text: 'Overzicht'
}]
}
}, {
xtype: 'menuitem',
text: 'Producten',
menu: {
xtype: 'menu',
items: [{
xtype: 'menuitem',
text: 'Overzicht'
},{
xtype: 'menuitem',
text: 'Artikelen'
},{
xtype: 'menuitem',
text: 'Groepen'
},{
xtype: 'menuitem',
text: 'Type',
handler: 'onClickButton',
},{
xtype: 'menuitem',
text: 'Soort'
},{
xtype: 'menuitem',
text: 'Merk'
}]
}
}, {
xtype: 'menuitem',
text: 'Klanten'
}]
}
},
{
xtype: 'menuitem',
text: 'verkoop'
}
]
}
}]
}]
}
]
});
when i click on an item i use a basic handler. This is located in my mainController file:
Ext.define('JustRent.view.main.MainController', {
extend: 'Ext.app.ViewController',
requires: [
],
alias: 'controller.main',
onClickButton: function () {
console.log('click works');
}
});
this is my ProductenType
Ext.define('JustRent.view.main.ProductenType', {
extend: 'Ext.grid.Panel',
alias: 'widget.ProductenType',
requires: [
// alerts
],
xtype: 'gridpanel',
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'string',
text: 'String'
},
{
xtype: 'numbercolumn',
dataIndex: 'number',
text: 'Number'
},
{
xtype: 'datecolumn',
dataIndex: 'date',
text: 'Date'
},
{
xtype: 'booleancolumn',
dataIndex: 'bool',
text: 'Boolean'
}
]
});
but now is my question how can i load the JustRent.view.main.ProductenType into the panel with the id 'contenBlock'.
I would use a Viewport as my main container
http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.container.Viewport
with a border layout http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.layout.container.Border
and then use add http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.container.Viewport-method-add
and remove methods http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.container.Viewport-method-remove
for component manipulation within the Viewport
pro tip: avoid unnecessary over nesting of components, use the lighter Component possible in each case. e.g containers are lighter in the DOM compared to panels so if you only need a container don't use a panel (not saying this is the case) .
Also I recommend Extjs in Action, awesome book that will help you really understand the framework.

How can I make ExtJS 4.2.1 empty grid respect flex layout value?

SOLUTION:
To better show the problem our actual code was facing, the following code works.
The keys for me to get this to work were to give border layout an 'align' config of stretch, and to ensure that containers had 'flex' config of 1 where necessary.
Ext.define('MyGrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.myGrid',
columns: [{text: 'First Name'}],
store: Ext.create('Ext.data.Store', {fields: ['fname']})
});
Ext.define('MyView', {
extend: 'Ext.container.Container',
alias: 'widget.myView',
layout: {
type: 'vbox',
align: 'stretch'
},
items: [{
xtype: 'myGrid',
title: 'My First Grid',
flex: 7,
bodyStyle: {
backgroundColor: '#ff0000'
}
}, {
xtype: 'myGrid',
title: 'My Second Grid',
flex: 3,
bodyStyle: {
backgroundColor: '#0000ff'
}
}]
});
Ext.onReady(function() {
Ext.create('Ext.container.Viewport', {
renderTo: Ext.getBody(),
layout: 'fit',
items: [{
layout: {
type: 'border',
align: 'stretch'
},
items: [{
xtype: 'container',
region: 'center',
itemId: 'gridsContainer',
layout: {
type: 'vbox',
align: 'stretch'
},
items: [{
xtype: 'myView',
flex: 1
}]
}]
}]
});
});
ORIGINAL POST:
In the code below, if you replace:
Ext.create('Ext.container.Container'
with:
Ext.create('Ext.container.Viewport'
The grids correctly occupy 70%/30% of the available area.
But when the code has Container and not Viewport, the grids are very small.
Of course my real code is within a larger application, so I cannot use a Viewport at that point, I must use container.
Ext.define('MyGrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.myGrid',
columns: [{
text: 'First Name',
dataIndex: 'fname'
}],
store: Ext.create('Ext.data.Store', {
fields: ['fname']
})
});
Ext.onReady(function() {
Ext.create('Ext.container.Container', {
renderTo: Ext.getBody(),
layout: 'fit',
items: [{
xtype: 'container',
layout: {
type: 'vbox',
align: 'stretch'
},
defaults: {
autoScroll: true,
bodyPadding: 0
},
items: [{
xtype: 'myGrid',
itemId: 'grid1',
flex: 7
}, {
xtype: 'splitter'
},{
xtype: 'tabpanel',
itemId: 'mypanel',
width: 400,
height: 400,
renderTo: document.body,
flex: 3,
scroll: true,
resizable: false,
activeTab: 0,
items: [{
xtype: 'myGrid',
itemId: 'tabgrid1',
title: 'My Grid Tab One'
},{
xtype: 'myGrid',
itemId: 'tabgrid2',
title: 'My Grid Tab Two'
}],
tabBar:{
//plain:true,
items:[{
xtype: 'tbfill'
},{
text:'????',
xtype:'image',
src: 'panelCollapseBtn.png',
closable: false,
listeners:{
'afterrender':function (comp) {
comp.getEl().on('click', function (el) {
// alert(comp.up('#mypanel').getCollapsed());
var panel = comp.up('#mypanel');
var isCollapsed = panel.getCollapsed();
//alert('is collapsed: ' + isCollapsed);
panel.header = !isCollapsed;
//panel.collapsible =isCollapsed;
comp.setSrc(isCollapsed?"panelCollapseBtn.png":"panelExpandBtn.png");
panel.toggleCollapse();
}, this);
comp.getEl().on('mouseover', function (el) {
el.target.style.cursor = "pointer";
}, this);
}
}
}]
}
}]
}]
});
});

How to initiate another class object in a view file in sencha

I have two view files list1.js and list2.js. in my 3rd view file mainTool.js when I am adding objects for above two classes, but it gives me the following error.
But when I try this in directly in app.js no error is given. Please help me
Uncaught ReferenceError: list1 is not defined
Ext.define('test.view.mainTool', {
extend: ['Ext.Container'],
requires: ['Ext.field.Search',
'test.view.list',
'test.view.list2',
'Ext.Toolbar'],
initialize: function () {
var list1 = Ext.create('test.view.list');
var list2 = Ext.create('test.view.list2');
list2.setHidden(true);
},
config: {
items: [{
xtype: 'toolbar',
docked: 'top',
ui: 'normal',
items: [{
xtype: 'searchfield',
placeHolder: 'Search...',
left: true,
id: 'mainSearch',
width: 200,
}, {
xtype: 'button',
ui: 'action',
text: 'filter',
id: 'filter'
}, {
xtype: 'spacer'
}, {
xtype: 'button',
ui: 'action',
text: 'showOnMap',
id: 'showOnMap'
}, {
xtype: 'button',
ui: 'action',
iconCls: 'arrow_left',
id: 'back'
}, {
xtype: 'button',
ui: 'action',
iconCls: 'home',
id: 'home'
}
]
},
list1, {
xtype: 'spacer'
},
list2,
]
}
});
Call the parent method first and add the items in your inizialize method and not in the config options:
initialize: function () {
this.callParent(arguments);
var list1 = Ext.create('test.view.list');
var list2 = Ext.create('test.view.list2');
list2.setHidden(true);
this.items = [{
xtype: 'toolbar',
docked: 'top',
ui: 'normal',
items: [{
xtype: 'searchfield',
placeHolder: 'Search...',
left: true,
id: 'mainSearch',
width: 200,
}, {
xtype: 'button',
ui: 'action',
text: 'filter',
id: 'filter'
}, {
xtype: 'spacer'
}, {
xtype: 'button',
ui: 'action',
text: 'showOnMap',
id: 'showOnMap'
}, {
xtype: 'button',
ui: 'action',
iconCls: 'arrow_left',
id: 'back'
}, {
xtype: 'button',
ui: 'action',
iconCls: 'home',
id: 'home'
}
]
},
list1, {
xtype: 'spacer'
},
list2,];
}

Rally SDK 2.00 p2 Adding several Checkboxes

I am trying to add Checkboxes for a Rally Report version 2.00p2.
I defined severals place holders for the filter (releaseFilter and stateFilter)
and Adding the checkboxes at the body of the onReady function at the end.
However, Instead of 5 different checkbox I get 1 and on top of the Release filter.
Sorry But I couldn't add an Image.
Rally.onReady(function() {
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
autoScroll: 'true',
items: [
{
xtype: 'container',
itemId: 'releaseFilter',
style: {
margin: '5px'
}
},
{
xtype: 'container',
itemId: 'stateFilter',
style: {
margin: '5px'
}
},
{
xtype: 'container',
itemId: 'grid',
style: {
margin: '10px',
}
},
// SOME CODE
],
launch: function() {
Rally.data.ModelFactory.getModel({
type: 'UserStory',
success: function(model) {
this.grid = this.add({
xtype: 'rallygrid',
model: model,
columnCfgs: [
'FormattedID',
'Release',
'Iteration',
'PlanEstimate',
'PlanDevEstDays',
'PlanQAEstDays'
],
storeConfig: {
filters: [
{
property: 'ScheduleState',
operator: '=',
value: 'Accepted'
}
]
}
});
this.down('#releaseFilter').add(
{
xtype: 'rallyreleasecombobox'
}
);
this.down('#stateFilter').add([{
xtype: 'menucheckitem',
text: 'Backlog',
floating: 'false'
},{
xtype: 'menucheckitem',
text: 'Defined'
},{
xtype: 'menucheckitem',
text: 'In-Progress'
},{
xtype: 'menucheckitem',
text: 'Completed'
},{
xtype: 'menucheckitem',
text: 'Accepted'
}]
);
},
scope: this
});
}
});
Rally.launchApp('CustomApp', {
name: 'Grid Example'
});
});
The original Entry in your javadoc is:
Ext.create('Ext.menu.Menu', {
width: 100,
height: 110,
floating: false, // usually you want this set to True (default)
renderTo: Ext.getBody(), // usually rendered by it's containing component
items: [{
xtype: 'menucheckitem',
text: 'select all'
},{
xtype: 'menucheckitem',
text: 'select specific',
},{
iconCls: 'add16',
text: 'icon item'
},{
text: 'regular item'
}]
});
What did I do wrong ?
Instead of using menucheckitem, use a standard Ext checkbox. Like this:
this.down('#stateFilter').add([{
xtype: 'checkbox',
fieldLabel: 'Backlog'
},
...
]);
Be sure change it from text to fieldLabel

Resources