ExtJS fluid panels - extjs

I'm coming from Twitter Bootstrap into ExtJS and unsure how to use which components in order to have a "row" which displays as many containers across the screen as will fit and then wrap them down.
Green boxes are where I would like to move the 2 grids:
Ext.onReady(function(){
Ext.define('Test', {
extend: 'Ext.data.Model',
fields: [
'created',
'name'
]
});
var testStore = Ext.create('Ext.data.Store', {
model: 'Test',
data: [
{
name: 'Do Something To Something Else',
created: 'Wednesday'
},
{
name: 'Do Another Thing To Another Thing',
created: 'Thursday'
}
]
});
var activeTasksApplet = Ext.create('Ext.panel.Panel', {
title: 'Active Tasks',
width: 350,
height: 200
});
var testsGrid = Ext.create('Ext.grid.Panel', {
store: testStore,
width: 400,
height: 200,
title: 'Tests',
columns: [
{
text: 'Name',
width: 100,
sortable: false,
hideable: false,
dataIndex: 'name'
}
]
});
var pageContents = Ext.create('Ext.container.Viewport', {
layout: 'border',
defaults: {
collapsible: false,
split: true,
bodyStyle: 'padding:15px'
},
items: [
{
title: 'Header',
region: 'north',
height: 120,
minSize: 75,
maxSize: 150,
cmargins: '5 0 0 0'
},
{
title: 'Panels',
region: 'center',
margins: '5 0 0 0',
items: [
testsGrid,
{
title: 'Active Tasks',
margins: '5 0 0 0',
width: 400,
height: 200,
items: Ext.create('Ext.grid.Panel', {
store: testStore,
width: 400,
height: 200,
title: 'Tests',
columns: [
{
text: 'Name',
width: 100,
sortable: false,
hideable: false,
dataIndex: 'name'
}
]
})
},
Ext.create('Ext.grid.Panel', {
store: testStore,
width: 400,
height: 200,
title: 'Tests',
columns: [
{
text: 'Name',
width: 100,
sortable: false,
hideable: false,
dataIndex: 'name'
}
]
}),
{
title: 'Active Tasks',
margins: '5 0 0 0',
},
{
title: 'Active Tasks',
margins: '5 0 0 0',
}
]
}]
});
});

Update:
Okay, this time for the correct solution.
Use the column layout, it treats the items as divs with float
Docs: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.layout.container.Column
Fiddle: http://jsfiddle.net/8Pqtx/8/
Ext.onReady(function(){
Ext.define('Test', {
extend: 'Ext.data.Model',
fields: [
'created',
'name'
]
});
var testStore = Ext.create('Ext.data.Store', {
model: 'Test',
data: [
{
name: 'Do Something To Something Else',
created: 'Wednesday'
},
{
name: 'Do Another Thing To Another Thing',
created: 'Thursday'
}
]
});
var activeTasksApplet = Ext.create('Ext.panel.Panel', {
title: 'Active Tasks',
height: 200
});
var testsGrid = Ext.create('Ext.grid.Panel', {
store: testStore,
width: 300,
height: 200,
title: 'Tests',
columns: [
{
text: 'Name',
sortable: false,
hideable: false,
dataIndex: 'name'
}
]
});
var pageContents = Ext.create('Ext.container.Viewport', {
layout: 'border',
defaults: {
collapsible: false,
split: true,
bodyStyle: 'padding:15px'
},
items: [
{
title: 'Header',
region: 'north',
height: 120,
minSize: 75,
maxSize: 150,
cmargins: '5 0 0 0'
},
{
title: 'Panels',
layout: 'column',
width: 500,
region: 'center',
items: [
testsGrid,
{
title: 'Active Tasks',
width: 200,
height: 200,
items: Ext.create('Ext.grid.Panel', {
store: testStore,
height: 200,
title: 'Tests',
columns: [
{
text: 'Name',
width: 100,
sortable: false,
hideable: false,
dataIndex: 'name'
}
]
})
},
Ext.create('Ext.grid.Panel', {
store: testStore,
width: 300,
height: 200,
title: 'Tests',
columns: [
{
text: 'Name',
width: 100,
sortable: false,
hideable: false,
dataIndex: 'name'
}
]
}),
{
title: 'Active Tasks',
width: 100
},
{
title: 'Active Tasks',
width: 100
}
]
}]
});
});

Related

How to switch between cards in card layout

I have a card layout having two cards one with tab panel.Inside tab panel grid panel is there and another card is my content panel. I have to switch to next card i.e my content panel on cell click on my grid panel.
Have used the setActiveitem() function but something is wrong.
extend: Ext.panel.Panel,
id: 'cardpanel',
width: 300,
height: 1000,
reference: 'resultcardPanel',
itemid: 'cardPanel',
layout: {
type: 'card',
anchor: '100%'
},
activeItem: 0,
xtype: 'searchresults',
bodyStyle: 'padding:15px',
defaults: {
border: false
},
controller: 'email',
viewModel: {
type: 'email'
},
items: [{
xtype: 'tabpanel',
//id:'searchresults',
requires: [
'Ext.grid.Panel',
'Ext.toolbar.Paging',
'Ext.grid.column.Date'
],
cls: 'shadow',
activeTab: 0,
margin: 20,
///////////////////////////////////////////////////////
items: [{
xtype: 'grid',
cls: 'allRecordsCls',
scrollable: false,
border: false,
title: 'Primary',
routeId: 'inbox',
bind: '{inbox}',
itemclick: function() {
centerpanel = new Ext.Panel({
layout: 'card',
items: [homepanel, browser.grid]
});
centerpanel.getLayout().setActiveItem(1);
},
selModel: {
selType: 'checkboxmodel',
checkOnly: true,
showHeaderCheckbox: true
},
headerBorders: false,
rowLines: false,
scrollable: false,
listeners: {
itemclick: 'onGridCellItemClick2'
},
columns: [
{
dataIndex: 'from',
text: 'From',
width: 140,
},
{
dataIndex: 'title',
text: 'Subject',
flex: 1,
},
{
xtype: 'datecolumn',
dataIndex: 'received_on',
width: 90,
text: 'Received On'
}
],
},
//////////////////////////////////////////////////////////
{
xtype: 'grid',
cls: 'allRecordsCls',
scrollable: false,
border: false,
title: 'Social',
routeId: 'inbox',
bind: '{inbox}',
listeners: {
itemclick: 'clickme'
},
selModel: {
selType: 'checkboxmodel',
checkOnly: true,
showHeaderCheckbox: true
},
headerBorders: false,
rowLines: false,
scrollable: false,
columns: [
{
dataIndex: 'from',
text: 'From',
width: 140,
},
{
dataIndex: 'title',
text: 'Subject',
flex: 1,
},
{
xtype: 'datecolumn',
dataIndex: 'received_on',
width: 90,
text: 'Received On'
}
],
},
///////////////////////////////////////////////////////
{
xtype: 'grid',
cls: 'allRecordsCls',
scrollable: false,
border: false,
title: 'Promotion',
routeId: 'inbox',
bind: '{inbox}',
selModel: {
selType: 'checkboxmodel',
checkOnly: true,
showHeaderCheckbox: true
},
listeners: {
itemclick: 'onGridCellItemClick2'
},
headerBorders: false,
rowLines: false,
scrollable: false,
columns: [
{
dataIndex: 'from',
text: 'From',
width: 140,
},
{
dataIndex: 'title',
text: 'Subject',
flex: 1,
},
{
xtype: 'datecolumn',
dataIndex: 'received_on',
width: 90,
text: 'Received On'
}
],
},
],
},
///////////////////////////////////////////
{
id: 'cardPanel',
xtype: 'emaildetails'
},
]
what to write in function in "onGridCellItemClick2" which is declared in controller

extjs6, expand chart component to fit column

In my extjs6 project, in the current page I have a column layout. Inside column 2 I have a chart. How can I make the chart fill that column in height and width? Everything I try is not working.
Below is my view, column 1 has small components so no need to expand contents. I've tried 'fit' height '100%', nothing seems to work properly. also, I am populating the chart AFTER the view is created. not sure if that matters
Ext.define('xxx.view.historical.Historical', {
extend: 'Ext.Panel',
xtype: 'app-historical',
controller: 'historicalController',
itemId: 'historicalItemId',
viewModel: 'historicalVM',
requires: [
'xxx.view.historical.HistoricalController',
'xxx.util.GlobalVar',
'Ext.chart.*'
],
title: 'Historical',
layout: 'fit',
items: [{
xtype: 'tabpanel',
margin: 10,
tabBar: {
layout: {
pack: 'left'
},
border: true
},
style: {
'border-radius': '4px 4px 4px 4px',
'box-shadow': '0 0 5px rgba(0, 0, 0, 0.3)'
},
defaults: {
iconAlign: 'top',
bodyPadding: 0
},
items: [{
title: 'Profit By Instrument',
autoScroll: true,
layout: {
type: 'column'
},
width: '100%',
items: [{
columnWidth: 0.20,
items: [{
xtype: 'combobox',
fieldLabel: 'Account',
emptyText: 'Select Account',
editable: false,
margin: 5,
displayField: 'AcctNum',
valueField: 'AcctNum',
bind: {
store: '{myAccountSummaryStore}'
},
listeners: {
select: 'onComboboxSelect'
},
queryMode: "local"
//combobox to select account
}, {
xtype: 'fieldcontainer',
fieldLabel: 'Instruments',
defaultType: 'checkboxfield',
itemId: 'itemIdCheckboxContainer',
margin: 5,
//cls: 'my-class',
items: [{
boxLabel: 'Anchovies',
name: 'topping',
inputValue: '1',
id: 'checkbox1',
cls: 'ownClass'
}]
}, {
xtype: 'button',
text: 'Select All'
}, {
xtype: 'button',
text: 'Deselect All'
}]
}, {
//COLUMN 2
columnWidth: 0.80,
items: [{
xtype: 'chart',
title: 'this is my title',
itemId: 'chartId',
margin: 5,
width: '100%',
height: '100%',
legend: {
docked: 'bottom'
},
axes: [{
type: 'numeric',
position: 'left',
fields: ['cumulativePl'],
title: 'Pl'
}, {
type: 'time',
position: 'bottom',
fields: ['filedate'],
title: 'Filedate',
//renderer: 'onAxisLabelRender',
label: {
rotate: {
degrees: -40
}
}
}]
}]
}]
}, {
title: 'Profit By Account',
autoScroll: true,
items: []
}]
}]
});
Just set the column layout to fit, it should work:
columnWidth: 0.40,
layout: {
type: 'fit'
},
Check out this FIDDLE

Extjs 5 - Link my grid to the Viewmodel

I manage to put the datas I need in a modelView
Controller.js
init: function ()
{
var me = this;
this.mainView = this.getView().add(Ext.create('Tsi.app.tsp_use.details.MainView'));
var customer_id = this.view.customer_id;
var transaction_id = this.view.transaction_id;
this.mainView.on('afterrender', function () {
//Recherche des infos de la transaction
Ext.Ajax.request({
url: '/app/tspuse/detail',
params:
{
customer_id: customer_id,
transaction_id: transaction_id
},
success: function (response)
{
//Passer de l'item "page de chargement" à l'item suivant ici (1)
me.mainView.getLayout().setActiveItem(1);
//response.data tab clef => $valeur
me.mainView.getViewModel().setData(response.data);
console.log('hello : ', response.data);
console.log('hello 2: ', me.mainView.getViewModel());
console.log('hello 3: ', me.mainView.getViewModel().data.vouchers_detail);
}
});
});
},
Here are the datas in the console :
console datas
But I don't know how to bind them to my grind in the third tab of my mainView (see comments) :
Ext.define('Tsi.app.tsp_use.details.MainView', {
extend: 'Tsi.os.view.BaseAppView',
bodyCls: 'DPEW_body_detail',
layout: 'card',
viewModel: {
data: {}
},
items: [{
xtype: 'container',
cls: 'directpayment_detail_help',
layout: 'center',
html: '<p>' + 'directpayment_transaction.wait'._() + '</p>'
}, {
border: false,
xtype: 'tabpanel',
buttonAlign: 'left',
titleAlign: 'left',
plain: true,
tabPosition: 'left',
tabRotation: 0,
defaults: {
border: false,
buttonAlign: 'left',
titleAlign: 'left'
},
listeners: {
tabchange: 'onTabChange'
},
items: [
/**
* FIRST TAB
*/
{
icon: '/img/icons/16/man.png',
bodyStyle: 'background: url(/img/icons/256/Search-Male-User_alpha.png) no-repeat bottom right',
xtype: 'panel',
title: 'directpayment_transaction.tab_user'._(),
tbar: [
'->',
{
xtype: 'container',
text: 'directpayment_transaction.customer.head_text'._()
},
{
icon: '/img/icons/16/text_list_bullets.png',
text: 'directpayment_transaction.customer.show_all_transaction'._(),
handler: 'customerShowAllTransactions'
},
{
icon: '/img/icons/16/Bar-chart.png',
text: 'directpayment_transaction.customer.show_chart_transaction'._(),
handler: 'customerShowStats'
},
],
layout: 'fit',
items: {
border: false,
padding: 10,
xtype: 'fieldcontainer',
labelAlign: 'top',
labelWidth: 100,
defaults: {
margin: 0,
padding: 0,
labelSeparator: '',
hideEmptyLabel: false
},
items: [{
hideLabel: true,
fieldLabel: '',
xtype: 'displayfield',
//pour la date : customer_birth_date:this.toDate -> applique la fonction toDate du Controller
bind: {
value: '{customer_first_name:htmlEncode} {customer_last_name:htmlEncode} - {customer_birth_date:htmlEncode}'
},
cls: 'directpayment_detail_group'
},
{
fieldLabel: 'directpayment_transaction.customer.address'._(),
xtype: 'displayfield',
bind: {
value: '{customer_address:htmlEncode}'
}
},
{
fieldLabel: ' ',
xtype: 'displayfield',
bind: {
value: '{customer_zipcode:htmlEncode} {customer_city:htmlEncode}'
}
},
{
fieldLabel: ' ',
xtype: 'displayfield',
bind: {
value: '{customer_country:htmlEncode}'
}
},
{
fieldLabel: 'directpayment_transaction.customer.phone'._(),
xtype: 'displayfield',
bind: {
value: '{customer_phone:htmlEncode}'
}
},
{
fieldLabel: 'directpayment_transaction.customer.mobile'._(),
xtype: 'displayfield',
bind: {
value: '{customer_mobile:htmlEncode}'
}
},
{
fieldLabel: 'directpayment_transaction.customer.email'._(),
xtype: 'displayfield',
bind: {
value: '{customer_email:this.toMail}'
}
}
]
}
},
/**
* SECOND TAB
*/
{
icon: '/img/icons/16/money_euro.png',
bodyPadding: 10,
title: 'directpayment.panel_detail.tab_transaction'._(),
bodyStyle: 'background: url(/img/icons/256/shopping-basket-full_alpha.png) no-repeat bottom right',
layout: 'fit',
overflowY: 'auto',
items: {
border: false,
padding: 10,
xtype: 'fieldcontainer',
labelAlign: 'top',
labelWidth: 100,
defaults: {
margin: 0,
padding: 0,
labelSeparator: '',
labelWidth: 200,
hideEmptyLabel: false
},
items: [{
hideLabel: true,
fieldLabel: '',
xtype: 'displayfield',
bind: {
value: '{payment_status:this.renderStatus}'
},
cls: 'directpayment_detail_group'
},
{
fieldLabel: 'directpayment_transaction.transaction.date'._(),
xtype: 'displayfield',
//pour la date : transaction_dtime_creation:this.toDate -> applique la fonction toDate du Controller
bind: {
value: '{transaction_dtime:this.toDateStr}'
}
},
{
fieldLabel: 'directpayment_transaction.transaction.tids'._(),
xtype: 'displayfield',
bind: {
value: '{transaction_tid:htmlEncode}'
}
},
{
fieldLabel: 'directpayment_transaction.transaction.amount'._(),
xtype: 'displayfield',
bind: {
value: '{transaction_amount:this.toMoney}'
}
},
{
fieldLabel: 'directpayment_transaction.transaction.currency'._(),
xtype: 'displayfield',
bind: {
value: '{transaction_currency:htmlEncode}'
}
},
{
fieldLabel: 'directpayment_transaction.transaction.detail'._(),
xtype: 'displayfield',
bind: {
value: '{transaction_detail}'
}
},
{
fieldLabel: 'directpayment_v1_transaction.merchant.name'._(),
xtype: 'displayfield',
bind: {
value: '{merchant_label}'
}
},
]
}
},
/**
* THIRD TAB
*/
{
icon: '/img/icons/16/barcode-16.png',
bodyPadding: 10,
title: 'tsp_use.panel_detail.tab_vouchers.title'._(),
bodyStyle: 'background: url(/img/icons/256/shopping-basket-full_alpha.png) no-repeat bottom right',
layout: 'fit',
overflowY: 'auto',
items: {
border: false,
padding: 10,
xtype: 'grid',
labelAlign: 'top',
labelWidth: 100,
defaults: {
margin: 0,
padding: 0,
labelSeparator: '',
labelWidth: 200,
hideEmptyLabel: false
},
columns: [{
text: 'tsp_use.panel_detail.tab_vouchers.voucher_ticket_sn'._(),
dataIndex: 'voucher_ticket_sn',
flex: 1
},
{
text: 'tsp_use.panel_detail.tab_vouchers.voucher_ticket_amount'._(),
dataIndex: 'voucher_ticket_amount',
flex: 1
},
{
text: 'tsp_use.panel_detail.tab_vouchers.voucher_ticket_balance'._(),
dataIndex: 'voucher_ticket_balance',
flex: 1
},
{
text: 'tsp_use.panel_detail.tab_vouchers.merchant_id'._(),
dataIndex: 'merchant_id',
flex: 1
},
{
text: 'tsp_use.panel_detail.tab_vouchers.merchant_name'._(),
dataIndex: 'merchant_name',
flex: 1
},
{
text: 'tsp_use.panel_detail.tab_vouchers.merchant_address'._(),
dataIndex: 'merchant_address',
flex: 1
},
{
text: 'tsp_use.panel_detail.tab_vouchers.merchant_zipcode'._(),
dataIndex: 'merchant_zipcode',
flex: 1
},
{
text: 'tsp_use.panel_detail.tab_vouchers.merchant_city'._(),
dataIndex: 'merchant_city',
flex: 1
},
{
text: 'tsp_use.panel_detail.tab_vouchers.merchant_country'._(),
dataIndex: 'merchant_country',
flex: 1
},
],
store: {
fields: [
'voucher_ticket_sn',
'voucher_ticket_amount',
'voucher_ticket_balance',
'merchant_id',
'merchant_name',
'merchant_address',
'merchant_zipcode',
'merchant_city',
'merchant_country'
],
/*
* How to access datas in viewModel ?
*
* bind:{} instead of proxy:{} ?
*
*/
proxy: {
type: 'ajax',
url: '',
pageSize: 25,
reader: {}
},
autoLoad: false
},
}
},
]
}]
});
It works for the displayfield, but I failed to bind the datas to voucher_detail to my grid.
Try it this way:
viewModel: {
data: {
arrayData: undefined
},
stores: {
storeName: {
data: '{arrayData}'
}
}
}
and then you just need to bind the store to the grid.

ExtJS 4: even browser not prompt to save entered data into forms fields

ExtJS 4.1.1a
Simple authorization form (login & passowrd).
Even browser not prompt to save entered login and password values unlike standard html form with input's.
Sample code: http://jsfiddle.net/AllanStark/mKMfh/1/
Ext.create('Ext.window.Window', {
title: 'Test',
height: 430,
width: 335,
bodyPadding: '20 0 0 0',
draggable: false,
resizable: false,
closable: false,
layout: {
type: 'vbox',
align: 'center'
},
bodyStyle: {
background: '#FFFFFF'
},
items: [{
xtype: 'image',
width: 150,
height: 150,
src: 'images/logo.gif'
},{
xtype: 'form',
url: 'login.php',
standardSubmit: true,
border: 0,
width: 170,
padding: '20 0 20 0',
defaultType: 'textfield',
layout: 'vbox',
fieldDefaults: {
labelAlign: 'top',
msgTarget: 'qtip',
width: '100%'
},
items: [{
xtype:'textfield',
fieldLabel: 'Login',
name: 'login',
allowBlank: false
},{
xtype:'textfield',
fieldLabel: 'Password',
name: 'pass',
inputType: 'password',
allowBlank: false,
listeners: {
specialkey: function(field, e){
if (e.getKey() == e.ENTER) {
var form = field.up('form').getForm();
form.submit();
}
}
}
}],
buttons: [{
text: 'Ok',
formBind: true,
disabled: true,
handler: function() {
var form = this.up('form').getForm();
form.submit();
}
},{
text: 'Reset',
handler: function() {
this.up('form').getForm().reset();
}
}]
}]
}).show();​
To open the password dialog the html-attribut autocomplete must be "on". In Extjs its "off" and there's no method to change it only a 'workaround'.
So add this event to the listeners of password and username:
afterrender:function(cmp){
cmp.inputEl.set({
autocomplete:'on'
});
}
Ext.create('Ext.window.Window', {
title: 'Test',
height: 430,
width: 335,
bodyPadding: '20 0 0 0',
draggable: false,
resizable: false,
closable: false,
layout: {
type: 'vbox',
align: 'center'
},
bodyStyle: {
background: '#FFFFFF'
},
items: [{
xtype: 'image',
width: 150,
height: 150,
src: 'images/logo.gif'
},{
xtype: 'form',
url: 'login.php',
standardSubmit: true,
border: 0,
width: 170,
padding: '20 0 20 0',
defaultType: 'textfield',
layout: 'vbox',
fieldDefaults: {
labelAlign: 'top',
msgTarget: 'qtip',
width: '100%'
},
items: [{
xtype:'textfield',
fieldLabel: 'Login',
name: 'login',
allowBlank: false,
listeners: {
// ------
afterrender:function(cmp){
cmp.inputEl.set({
autocomplete:'on'
});
}
// ------
}
},{
xtype:'textfield',
fieldLabel: 'Password',
name: 'pass',
inputType: 'password',
allowBlank: false,
listeners: {
specialkey: function(field, e){
if (e.getKey() == e.ENTER) {
var form = field.up('form').getForm();
form.submit();
}
},
// ------
afterrender:function(cmp){
cmp.inputEl.set({
autocomplete:'on'
});
}
// ------
}
}],
buttons: [{
text: 'Ok',
formBind: true,
disabled: true,
handler: function() {
var form = this.up('form').getForm();
form.submit();
}
},{
text: 'Reset',
handler: function() {
this.up('form').getForm().reset();
}
}]
}]
}).show();​

Combobox and button in ExtJS Composite field

Iam Using compositfield for Combobox and edit button as side by side
for this my code is
{
xtype: 'fieldset',
title: 'Covered under warranty',
checkboxToggle: true,
labelAlign: 'right',
autoHeight: true,
width: 730,
items: [{
bodyStyle: 'padding-left:5px;',
layout: 'table',
autoHeight: true,
autoWidth: true,
layoutConfig: {
columns: 2
},
defaults: {
frame: true,
style: 'margin: 0 0 1px 3px'
},
items: [{
xtype: 'fieldset',
title: 'Warranty Manufacturer',
autoHeight: true,
width: 360,
labelWidth: 110,
items: [{
xtype: 'compositefield',
defaults: {
height: 20
},
fieldLabel: 'Company',
items: [ComboComanyinWarranty, btnEdit]
}, {
xtype: 'compositefield',
defaults: {
height: 20
},
fieldLabel: 'Company Location',
width: 220,
items: [ComboCompanyLocationInWarranty]
}, {
xtype: 'compositefield',
defaults: {
height: 20
},
fieldLabel: 'Contact Person',
width: 220,
items: [ComboContactPersonInWarranty, {
xtype: 'button',
text: '...'
}]
}, {
xtype: 'compositefield',
defaults: {
height: 20
},
fieldLabel: 'Contact Phone',
items: [{
xtype: 'displayfield',
value: ''
}]
}, {
xtype: 'compositefield',
defaults: {
height: 20
},
fieldLabel: 'Contact Mobile',
items: [{
xtype: 'displayfield',
value: ''
}]
}, {
xtype: 'compositefield',
defaults: {
height: 20
},
fieldLabel: 'Contact Email',
items: [{
xtype: 'displayfield',
value: ''
}]
}]
}
}
but buttons are not displaying properly bottom part of the button cut.
so please help
Thanks in advance
Maybe autoheight isn't working? Try setting it to a fixed height...

Resources