Extjs 5 - Link my grid to the Viewmodel - extjs

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.

Related

How to add search filter in EXTJS

I created a table using extjs where it is having three columns name, email and cars. In extjs we are having a default sorting method. here i want to add search method for all these three columns so that i can also search using the name, email and cars.
What change i need to do for the below code
The expected output is i need to get search filter option under each columns.
Ext.define('ViewerModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.viewermodel',
stores: {
mystore: {
fields: ['name', 'email', 'cars'],
data: {
'items': [{
'name': 'Lisa',
"email": "lisa#simpsons.com"
}, {
'name': 'Bart',
"email": "bart#simpsons.com"
}, {
'name': 'Homer',
"email": "homer#simpsons.com"
}, {
'name': 'Marge',
"email": "marge#simpsons.com"
}]
},
proxy: {
type: 'memory',
reader: {
type: 'json',
rootProperty: 'items'
}
}
}
}
});
Ext.define('APP.HorizontalBox', {
extend: 'Ext.container.Container',
requires: ['Ext.layout.container.HBox'],
xtype: 'layout-horizontal-box',
width: 750,
height: 300,
layout: {
type: 'hbox',
align: 'stretch'
},
bodyPadding: 10,
defaults: {
frame: true,
bodyPadding: 10
},
viewModel: {
type: 'viewermodel'
},
items: [{
xtype: 'grid',
title: 'Grid: click on the grid rows',
itemId: 'myGridItemId',
flex: 1.2,
margin: '0 10 0 0',
bind: {
store: '{mystore}',
selection: '{users}'
},
columns: [{
text: 'Name',
dataIndex: 'name',
flex: 0.5
}, {
text: 'Email',
dataIndex: 'email',
flex: 1
}, {
text: 'Cars',
dataIndex: 'cars',
flex: 1
}],
dockedItems: [{
xtype: 'toolbar',
dock: 'top',
items: [{
xtype: 'button',
padding: '2 5 2 5',
text: 'Edit item',
handler: function (btn) {
var grid = btn.up('grid');
var selectedRow = grid.getSelectionModel().getSelection()[0];
var janela = Ext.create('APP.MyWindow', {
animateTarget: btn.getEl(),
//EDITED
viewModel: {
data: {
users: selectedRow
}
}
}).show();
}
}]
}],
}, {
xtype: 'form',
title: 'View',
itemId: 'panelbindItemId',
flex: 1,
margin: '0 10 0 0',
defaults: {
labelWidth: 50
},
items: [{
xtype: 'displayfield',
margin: '20 0 0 0',
fieldLabel: 'Name',
bind: '{users.name}'
}, {
xtype: 'displayfield',
fieldLabel: 'Email',
bind: '{users.email}'
}]
}]
});
Ext.define('APP.MyWindow', {
extend: 'Ext.window.Window',
alias: 'widget.mywindow',
reference: 'windowreference',
title: 'MyWindow | Edit record',
closable: true,
modal: true,
padding: '10px',
height: 150,
layout: 'fit',
initComponent: function () {
var me = this;
Ext.apply(me, {
items: [{
xtype: 'form',
layout: 'anchor',
defaults: {
padding: '5 0 5 0'
},
items: [{
xtype: 'textfield',
margin: '10 0 0 0',
fieldLabel: 'Name',
bind: '{users.name}'
}, {
xtype: 'textfield',
fieldLabel: 'Email',
bind: '{users.email}'
}]
}]
});
me.callParent(arguments);
}
});
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.create('APP.HorizontalBox', {
renderTo: document.body,
width: 750,
height: 400,
title: 'Title'
});
}
});
You can do it in the afterrender event of grid (Refer this post.) For example:
listeners: {
afterrender: function () {
var menu = Ext.ComponentQuery.query('grid')[0].headerCt.getMenu();
menu.add([{
text: 'Search',
iconCls: 'x-fa fa-home',
handler: function () {
console.log("Search Item");
}
}]);
}
}
Check this Fiddle.
What you are searching for is the FiltersFeature, and the usage is as follows:
xtype:'grid',
...
features:[{
ftype: 'filters',
local: true,
filters: [{
type: 'string',
dataIndex: 'name'
}, {
... (one definition for every column you want to allow filtering one)
}]
}]
Please note that you have to add a requires and maybe even load Ext.ux, as can be found in the last comment.
Other readers please be aware that FiltersFeature is ExtJS4 specific, and has been moved around for ExtJS 5 and 6.
You can also use this code where it will search the data using the date.
listeners: {
afterrender: function () {
var menu = Ext.ComponentQuery.query('grid')[0].headerCt.getMenu();
menu.add([{
xtype:'datefield',
name:'date1',
fieldLabel:'Filter By',
format: 'y-m-d',
listeners:{
renderer: Ext.util.Format.dateRenderer('y-m-d'),
field:{ xtype:'datefield',
autoSync:true,
allowBlank:false,
editor: new Ext.form.DateField(
{format: 'y-m-d'}) }
}
}

EXT JS how come the cellmodel are not editable?

Ext.define('RouteFareModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'Rate_ID', type: 'number'},
{name: 'Route_Fare' , type: 'int'},
'From_LocationName',
'To_LocationName',
'From_LocationID',
'To_LocationID',
'from_name',
'to_name',
'Route_ID',
'Normal_Rate',
'Discounted_Rate']
});
var RouteFareStore = Ext.create('Ext.data.JsonStore', {
model: 'RouteFareModel',
storeId: 'RouteFareStore',
autoLoad: false,
sorters: [{
property: 'Route_Fare',
direction: 'ASC'
}],
proxy: {
type: 'ajax',
url: 'get-routefare.php',
api: {
create: 'insert-routeseq.php',
//read: 'http://visual04/ModuleGestion/php/Pays.php?action=read',
update: 'update-routeseq.php',
//destroy: 'http://visual04/ModuleGestion/php/Pays.php?action=destroy'
},
actionMethods: 'POST',
baseParams: {
_id : 0,
},
reader: {
type: 'json',
idProperty: '_id'
},
writer: {
type: 'json',
id: '_id'
}
}
});
var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
Ext.define('MyApp.view.MyGridPanelRouteFare', {
extend: 'Ext.grid.Panel',
id:'MyGridPanelRouteFare',
alias: 'widget.mygridpanelroutefare',
renderTo: Ext.getBody(),
height: window.innerHeight,
width: window.innerWidth/3,
title: 'Route Fare Setting',
selModel: {
selType: 'cellmodel'
},
plugins: [cellEditing],
store: RouteFareStore,
columns: [
{
xtype:'gridcolumn',
width: 120,
dataIndex: 'from_name',
text: 'From Location'
},
{
xtype:'gridcolumn',
width: 120,
dataIndex: 'to_name',
text: 'To Location'
},
{
xtype:'gridcolumn',
width: 80,
dataIndex: 'Normal_Rate',
text: 'Normal Rate'
},
{
xtype:'gridcolumn',
width: 80,
dataIndex: 'Discounted_Rate',
text: 'Discount Rate'
}
],
dockedItems: [
{
xtype: 'toolbar',
dock: 'top',
height: 30,
items: [
{
xtype: 'combobox',
id:'cmbFareRouteID',
width: 191,
store: RouteNameStore,
valueField : "_id",
displayField : "Route_Code",
fieldLabel: 'Route Code',
labelWidth: 70,
editable: false,
queryMode: 'local',
listeners: {
select: function( combo, records, eOpts ) {
console.log("Combo selected _id : "+records[0].get('_id'));
RouteFareStore.load({
params:{
_id: records[0].get('_id')
}
});
}
}
},
{
xtype: 'button',
cls: '',
id: 'BtnFareCmbRefresh',
width: 65,
icon: '',
iconCls: 'refresh',
text: 'Refresh'
}
]
},
{
xtype: 'toolbar',
dock: 'top',
height: 30,
items: [
{
xtype: 'button',
cls: '',
id: 'BtnRouteFareSave',
width: 65,
icon: '',
iconCls: 'save',
text: 'Save'
},
{
xtype: 'button',
cls: '',
id: 'BtnRouteFareRefresh',
width: 65,
icon: '',
iconCls: 'refresh',
text: 'Refresh'
}
]
}
]
})
i have add
var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
but the grid cell still not able to editable. why?
{
xtype:'gridcolumn',
width: 80,
dataIndex: 'Normal_Rate',
text: 'Normal Rate',
field: {
xtype: 'numberfield',
allowBlank: false,
minValue: 0,
maxValue: 1000
}
},
must insert field: {} , then the cellmodel able to editable already.

Passing arguments to Listener

I have a button:
var me = this;
...
var argumentToPass;
...
{
xtype: 'button',
text: 'text',
listeners: {
click: {
fn: me.onBtnAddToBidClick,
scope: me
}
}
}
...
me has a refferance to the argumentToPass.
And the Listerner:
onBtnAddToBidClick: function(button, e, options){
alert(argumentToPass)
}
Basicly i am trying to make a simple function(String var) method.
How can i get the scope from inside the Listener(onBtnAddToBidClick)
EDIT: Thsi is most of my code:
Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.selection.CheckboxModel'
]);
var sm = Ext.create('Ext.selection.CheckboxModel');
Ext.define('MyApp.view.MyViewport', {
extend: 'Ext.container.Viewport',
layout: {
type: 'border'
},
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'panel',
region: 'west',
id: 'MenuPanelID',
width: 255,
layout: {
type: 'accordion'
},
collapsed: true,
collapsible: true,
title: 'תפריט',
items: [
{
xtype: 'form',
width: 148,
layout: {
align: 'stretch',
type: 'vbox'
},
collapsed: false,
title: 'מחירונים',
dockedItems: [
{
xtype: 'textfield',
flex: 1,
dock: 'top',
id: 'txtPrefixID',
margin: 10,
fieldLabel: 'Prefix',
labelWidth: 50
},
{
xtype: 'button',
flex: 1,
dock: 'top',
margin: 10,
text: 'חפש',
listeners: {
click: {
fn: me.onBtnPrefixSearchClick,
scope: me,
arg: 0
}
}
},
{
xtype: 'button',
flex: 1,
dock: 'top',
margin: 10,
text: 'חפש טווח',
listeners: {
click: {
fn: me.onBtnPrefixSearchClick,
scope: me,
arg: 1
}
}
}
]
}
]
},
{
xtype: 'tabpanel',
region: 'center',
id: 'MainTabPanelID',
activeTab: 0,
items: [
{
xtype: 'panel',
layout: {
type: 'border'
},
title: 'General',
items: [
{
xtype: 'container',
region: 'center',
layout: {
align: 'stretch',
type: 'vbox'
},
items: [
{
xtype: 'gridpanel',
flex: 1,
autoScroll: true,
title: 'שיחות נכנסות',
store: 'IncomingDataStore',
viewConfig: {
id: 'IncomingGridId'
},
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'trunk_owner',
text: 'Owner'
},
{
xtype: 'gridcolumn',
dataIndex: 'country_name',
text: 'Country'
},
{
xtype: 'gridcolumn',
dataIndex: 'country_code',
text: 'Code'
},
{
xtype: 'numbercolumn',
align: 'right',
dataIndex: 'operator_prefix',
text: 'Operator Prefix',
format: '00'
},
{
xtype: 'numbercolumn',
align: 'right',
dataIndex: 'call_duration',
text: 'Duration Hourly'
},
{
xtype: 'numbercolumn',
align: 'right',
dataIndex: 'acd',
text: 'ACD Hourly'
},
{
xtype: 'numbercolumn',
align: 'right',
dataIndex: 'asr',
text: 'ASR Hourly'
},
{
xtype: 'numbercolumn',
align: 'right',
dataIndex: 'calls',
text: 'Calls Hourly',
format: '0,000'
}
],
listeners: {
celldblclick: {
fn: me.onIncomingGridpanelCellDblClick,
scope: me
}
}
}
]
}
]
}
]
}
]
});
me.callParent(arguments);
},
onBtnPrefixSearchClick: function(arg) {
var checkBoxPrefixes = Ext.create('Ext.selection.CheckboxModel');
var val = Ext.getCmp('txtPrefixID').value;
var v_url = 'GetCountryPrefixes.jsp?' + Ext.urlEncode({'prefix': val, 'action': 'search_exact'});
alert(arg);
if arg === 0 {
// do something...
}
var me = this;
var newTab = Ext.create('Ext.panel.Panel', {
id: 'prefix_panel',
title: 'Price Usage Report',
autoScroll: true,
layout: {
type: 'fit'
},
closable: true,
dockedItems: [
{
xtype: 'toolbar',
dock: 'top',
items: [
{
xtype: 'button',
id: 'buttonBiding',
icon: 'images/dollar16x16.png',
text: 'הוסף להצעת מחיר',
listeners: {
click: {
fn: me.onBtnAddToBidClick,
scope: me
}
}
}
]
}
],
items: [{
id: 'prefix_grid',
xtype: 'gridpanel',
autoShow: false,
autoScroll: true,
selModel: checkBoxPrefixes,
store: Ext.create('Ext.data.Store', {
fields: [
{name: 'price_date'}, //, type: 'Date' , sortType: 'asDate', format: 'Y-m-d h:M:s'
{name: 'country_code',type: 'int', sortType: 'asInt'},
{name: 'prefix',type: 'int', sortType: 'asInt'},
{name: 'vendor_name'},
{name: 'rate', type: 'float', sortType: 'asFloat'},
{name: 'currency'},
{name: 'quality', type: 'int', sortType: 'asInt'},
{name: 'duration',type: 'int', sortType: 'asInt'},
{name: 'acd', type: 'float', sortType: 'asFloat'}
],
proxy: {
type: 'ajax',
timeout: 120000,
url: v_url,
reader: {
type: 'json',
root: 'data',
successProperty: 'success'
}
},
autoLoad: true
}),
title: 'Price Reprort for "' + val + '" - Monthly' ,
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'price_date',
width: 80,
text: 'Date',
renderer: Ext.util.Format.dateRenderer('Y-m-d')
},
{
xtype: 'gridcolumn',
dataIndex: 'country_code',
text: 'Counry Code',
width: 80
},
{
xtype: 'gridcolumn',
dataIndex: 'prefix',
text: 'Prefix',
width: 80
},
{
xtype: 'gridcolumn',
dataIndex: 'vendor_name',
width: 100,
text: 'Vendor Name'
},
{
xtype: 'gridcolumn',
dataIndex: 'currency',
width: 100,
text: 'Currency'
},
{
xtype: 'gridcolumn',
dataIndex: 'rate',
width: 50,
text: 'Rate'
},
{
xtype: 'gridcolumn',
dataIndex: 'quality',
width: 50,
text: 'Quality'
},
{
xtype: 'gridcolumn',
dataIndex: 'duration',
width: 100,
text: 'Duration'
},
{
xtype: 'gridcolumn',
dataIndex: 'acd',
width: 100,
text: 'ACD'
}
]
}]
});
var panel = Ext.getCmp("MainTabPanelID");
panel.remove('prefix_panel');
panel.add(newTab).show();
},
You cannot do it because you are not able to modify event args of a defined event.
But you can store the arguments you want to pass into the instance that fires the event or into the scope in which the event callback get executed. In that way you will have access to them either by the first event arg, which is in nearly all situations the instance that fires the event or by the this keyword when you have applied them to the scope.
Simplified example with data stored in callback scope:
fiddle

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