I have a several panels which layout is vbox and hbox
how can I implement maximum and minimum feature when dbclick the panel title
here is the code:
http://jsfiddle.net/SLHjn/
Ext.create('Ext.panel.Panel', {
style: 'padding:0 10px 0 10px',
layout: {
align: 'stretch',
type: 'vbox'
},
renderTo: Ext.getBody(),
items: [{
xtype: 'panel',
border: 0,
layout: {
align: 'stretch',
type: 'vbox'
},
items: [{
xtype: 'panel',
height: 100,
title: 'title1',
html: 'panel1'
}, {
xtype: 'panel',
height: 100,
title: 'title2',
html: 'panel2'
}]
}, {
xtype: 'panel',
border: 0,
layout: {
align: 'stretch',
type: 'hbox'
},
items: [{
xtype: 'panel',
title: 'title3',
height: 100,
flex: 1,
html: 'panel3'
}, {
xtype: 'panel',
title: 'title3',
flex: 1,
html: 'panel4'
}]
}]
});
I have two problems:
how to add dbclick event on panel title
if use collapse and expand, when dbclick on panel1, how to set panel3 and panel4 collapse top:
http://jsfiddle.net/SLHjn/1/
Thanks.
You should define dblclick event on the outer panel, then use toggleCollapse function, like below.
REMARK:
Do not use collapse and expand function which will not work. Juts use toggleCollapse
Ext.create('Ext.panel.Panel', {
style: 'padding:0 10px 0 10px',
layout: {
align: 'stretch',
type: 'vbox'
},
renderTo: Ext.getBody(),
items: [{
xtype: 'panel',
border: 0,
layout: {
align: 'stretch',
type: 'vbox'
},
items: [{
xtype: 'panel',
height: 100,
title: 'title1',
html: 'panel1',
listeners: {
dblclick: {
fn: function() {
var pnl = Ext.getCmp('panel-out');
pnl.toggleCollapse();
},
element: 'el'
}
}
}, {
xtype: 'panel',
height: 100,
title: 'title2',
html: 'panel2'
}]
}, {
xtype: 'panel',
border: 0,
id: 'panel-out',
layout: {
align: 'stretch',
type: 'hbox'
},
items: [{
xtype: 'panel',
title: 'title3',
height: 100,
flex: 1,
html: 'panel3'
}, {
xtype: 'panel',
title: 'title3',
flex: 1,
html: 'panel4'
}]
}]
});
UPDATE:
then, try this (I am just hide and show the panel )
Ext.create('Ext.panel.Panel', {
style: 'padding:0 10px 0 10px',
layout: {
align: 'stretch',
type: 'vbox'
},
renderTo: Ext.getBody(),
items: [{
xtype: 'panel',
border: 0,
layout: {
align: 'stretch',
type: 'vbox'
},
items: [{
xtype: 'panel',
height: 100,
title: 'title1',
html: 'panel1',
listeners: {
dblclick: {
fn: function() {
var pnl = Ext.getCmp('panel-out');
pnl.toggleCollapse();
},
element: 'el'
}
}
}, {
xtype: 'panel',
height: 100,
title: 'title2',
html: 'panel2'
}]
}, {
xtype: 'panel',
border: 0,
id: 'panel-out',
layout: {
align: 'stretch',
type: 'hbox'
},
items: [{
xtype: 'panel',
title: 'title3',
height: 100,
flex: 1,
html: 'panel3',
listeners: {
dblclick: {
fn: function() {
var pnl_three = Ext.getCmp('panel4');
if (pnl_three.hidden == false) {
pnl_three.hide();
} else {
pnl_three.show();
}
},
element: 'el'
}
}
}, {
xtype: 'panel',
title: 'title4',
id: 'panel4',
flex: 1,
html: 'panel4'
}]
}]
});
Related
I have a column setup with a cell formatter and is working fine.
{ title: "MKT Score", field: "MKTScore", width: 110, hozAlign: "center", formatter: "star", formatterParams: { stars: 3 }, },
what I'm look at trying to do is, if a value of a different cell is false is to hide the Formatter on a cell so it would be blank.
For some situations, such as the "star" formatter, you could pass a function to the formatterParams property in order to manupilate the formatter. Here is an example where, if the bool column is false, show blank:
const dataSet1 = [
{ id: 1, name: 'Billy Bob', bool: false, gender: 'male', rating: 2, col: 'red' },
{ id: 2, name: 'Mary May', bool: true, gender: 'female', rating: 3, col: 'blue' },
{ id: 3, name: 'Christine Lobowski', bool: false, gender: 'female', rating: 0, col: 'green' },
{ id: 4, name: 'Brendon Philips', bool: true, gender: 'male', rating: 2, col: 'orange' },
{ id: 5, name: 'Margret Marmajuke', bool: false, gender: 'female', rating: 0, col: 'yellow' }
]
const table = new Tabulator('#table', {
data: dataSet1,
columns: [
{ title: 'Name', field: 'name' },
{ title: 'Bool', field: 'bool' },
{ title: 'Gender', field: 'gender' },
{ title: 'Rating', field: 'rating', formatter: "star" , formatterParams: stars },
{ title: 'Favourite Color', field: 'col' }
]
})
function stars(row) {
return row.getData().bool ? { stars: 3 } : { stars: -1 }
}
<link href="https://unpkg.com/tabulator-tables#5.1.8/dist/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" src="https://unpkg.com/tabulator-tables#5.1.8/dist/js/tabulator.min.js"></script>
<div id="table"></div>
I am a beginner of extjs.
I want to arrange some TextFields as below:
a:______ b:______ c:______
d:______ e:______ f:______
here are my test codes below:
Ext.onReady(function()
{
new Ext.panel.Panel(
{
renderTo: Ext.getBody(),
layout:'vbox',
width: 670,
tbar: [{text:"Add"}],
defaults:
{
layout:"column",
height:50
},
items:
[
{
defaults:
{
labelAlign:"right",
labelWidth:50
},
items:
[
{
xtype: 'textfield',
fieldLabel: 'a'
},
{
xtype: 'textfield',
fieldLabel: 'b'
},
{
xtype: 'textfield',
fieldLabel: 'c'
}
]
},
{
defaults:
{
labelAlign:"right",
labelWidth:50
},
items:
[
{
xtype: 'textfield',
fieldLabel: 'd'
},
{
xtype: 'textfield',
fieldLabel: 'e'
},
{
xtype: 'textfield',
fieldLabel: 'f'
}
]
}
]
});
});
as a result, the page can't display any TextFields.
Thank you for any help in advance!
You can do something like :
new Ext.panel.Panel({
renderTo: Ext.getBody(),
width: 670,
tbar: [{
text: "Add"
}],
defaults: {
layout: ,
height: 50
},
items: [{
defaults: {
labelAlign: "right",
labelWidth: 50
},
items: [{
xtype: 'textfield',
fieldLabel: 'a'
}, {
xtype: 'textfield',
fieldLabel: 'b'
}, {
xtype: 'textfield',
fieldLabel: 'c'
}]
}, {
defaults: {
labelAlign: "right",
labelWidth: 50
},
items: [{
xtype: 'textfield',
fieldLabel: 'd'
}, {
xtype: 'textfield',
fieldLabel: 'e'
}, {
xtype: 'textfield',
fieldLabel: 'f'
}]
}]
});
It is essentially your same example except replacing the vbox layout with the default auto layout. The reason why you example didn't work is that vbox layouts need a height and width set on it somehow.
You could also do something like :
new Ext.panel.Panel({
renderTo: Ext.getBody(),
layout: 'column',
width: 670,
tbar: [{
text: "Add"
}],
defaults: {
labelAlign: "right",
labelWidth: 50
},
items: [{
xtype: 'textfield',
fieldLabel: 'a'
}, {
xtype: 'textfield',
fieldLabel: 'b'
}, {
xtype: 'textfield',
fieldLabel: 'c'
}, {
xtype: 'textfield',
fieldLabel: 'd'
}, {
xtype: 'textfield',
fieldLabel: 'e'
}, {
xtype: 'textfield',
fieldLabel: 'f'
}]
});
It is a column layout without the nested items as the one before. One nice thing about a column layout is that it will shift as many items as it can to the left and if an item can't fit it will go in the next row.
Since the width is a static 670 it can only fit 3 text fields per row. Column layouts do not need a height set.
I have created a form using ExtJs 4
xtype: 'prg-formPanel',
id: 'blog-edit-form', // id fixed : id: 'upload-form-'+this.filetype,
url: baseUrl + "crud",
border: 0,
bodyStyle: {
padding: '10px 20px'
},
height: 600,
defaultType: 'textfield',
defaults: {
anchor: '95%',
allowBlank: true,
msgTarget: 'side',
labelWidth: 60
},
layout: {
type: 'table',
columns: 2
},
items: [{
inputType: 'hidden',
id: 'actionType',
name: 'actionType',
value: this.actionType,
scope: this
},{
inputType: 'hidden',
id: 'id',
name: 'id',
value: (Ext.isEmpty(this.record)?null:this.record.get('id'))
},{
inputType: 'textfield',
id: 'title',
fieldLabel: 'Başlık',
name: 'title',
labelWidth: 60,
value: (Ext.isEmpty(this.record)?null:this.record.get('title')),
colspan:2
},{
inputType: 'textfield',
id: 'name',
fieldLabel: 'İsim',
name: 'name',
labelWidth: 60,
value: (Ext.isEmpty(this.record)?null:this.record.get('name')),
colspan:2
},
new Prg.checkBox({
fieldLabel: 'Aktif mi?',
name: 'activeFlag',
labelWidth: 60,
checked: (Ext.isEmpty(this.record)?false:this.record.get('activeFlag'))
}),
new Prg.idCombo({
fieldLabel : 'Dil',
labelWidth: 60,
emptyText : 'Dili seçiniz...',
id: 'langId',
name : 'langId',
store : this.ds_language,
scope: this
}),{
inputType: 'textfield',
id: 'targetURL',
fieldLabel: 'Link',
name: 'targetURL',
labelWidth: 60,
value: (Ext.isEmpty(this.record)?null:this.record.get('targetURL')),
colspan:2
},{
xtype: "TinyMCEEditor",
fieldLabel: "İçerik",
width: 800,
height: 400,
colspan:2,
name: "contentHTML",
id: "contentHTML",
tinyMCESettings: {
mode: "exact",
theme: "advanced",
skin: "o2k7",
// Tiny Settings Here
//...
value: (Ext.isEmpty(this.record)?"":this.record.get('contentHTML'))
},
new Ext.form.field.ComboBox({
id: "categories",
name: "categories",
fieldLabel: 'Kategori',
multiSelect: true,
displayField: 'name',
forceSelection: true,
labelWidth: 60,
store: this.ds_tags,
queryMode: 'remote',
scope: this,
colspan:2
})
] // Form items closure
}];
this.buttons = [new Prg.btn({
text: btnUploadMsg,
handler: this.onSave,
scope: this
}),new Prg.btn({
text: btnCancelMsg,
handler: function() {
this.hide();
},
scope: this
})];
this.callParent(arguments);
this.form = this.getComponent('blog-edit-form').getForm(); // 'upload-form-'+this.filetype
}
as you see, I used table layout, some form items should be inline, others shoul be in the new line. I have done it by table, however, now items width is fixed...
I am also want to give them 95% value to get them resize automatically when window resize. I cant find the way. try to add anchor and width: '90%' but it does not work.
Use the default layout for forms: form and use FieldContainer http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.FieldContainer where you need to show two fields on the same row.
This way you can leverage anchor and still create a complex layout like the one you want.
This should work (i cannot test it because of custom types)
Ext.define('Prg.FormPanel', {
initComponent: function() {
Ext.applyIf(this, {
xtype: 'prg-formPanel',
id: 'blog-edit-form',
// id fixed : id: 'upload-form-'+this.filetype,
url: baseUrl + "crud",
border: 0,
bodyStyle: {
padding: '10px 20px'
},
height: 600,
defaultType: 'textfield',
defaults: {
anchor: '95%',
allowBlank: true,
msgTarget: 'side',
labelWidth: 60
},
layout: {
type: 'form'
},
items: [{
inputType: 'hidden',
id: 'actionType',
name: 'actionType',
value: this.actionType,
scope: this
}, {
inputType: 'hidden',
id: 'id',
name: 'id',
value: (Ext.isEmpty(this.record) ? null : this.record.get('id'))
}, {
inputType: 'textfield',
id: 'title',
fieldLabel: 'Başlık',
name: 'title',
labelWidth: 60,
value: (Ext.isEmpty(this.record) ? null : this.record.get('title'))
}, {
inputType: 'textfield',
id: 'name',
fieldLabel: 'İsim',
name: 'name',
labelWidth: 60,
value: (Ext.isEmpty(this.record) ? null : this.record.get('name'))
}, {
xtype: 'fieldcontainer',
layout: 'hbox',
items: [
new Prg.checkBox({
fieldLabel: 'Aktif mi?',
name: 'activeFlag',
labelWidth: 60,
checked: (Ext.isEmpty(this.record) ? false : this.record.get('activeFlag'))
}), new Prg.idCombo({
fieldLabel: 'Dil',
labelWidth: 60,
emptyText: 'Dili seçiniz...',
id: 'langId',
name: 'langId',
store: this.ds_language,
scope: this
})]
}, {
inputType: 'textfield',
id: 'targetURL',
fieldLabel: 'Link',
name: 'targetURL',
labelWidth: 60,
value: (Ext.isEmpty(this.record) ? null : this.record.get('targetURL'))
}, {
xtype: "TinyMCEEditor",
fieldLabel: "İçerik",
width: 800,
height: 400
name: "contentHTML",
id: "contentHTML",
tinyMCESettings: {
mode: "exact",
theme: "advanced",
skin: "o2k7",
// Tiny Settings Here
//...
value: (Ext.isEmpty(this.record) ? "" : this.record.get('contentHTML'))
},
new Ext.form.field.ComboBox({
id: "categories",
name: "categories",
fieldLabel: 'Kategori',
multiSelect: true,
displayField: 'name',
forceSelection: true,
labelWidth: 60,
store: this.ds_tags,
queryMode: 'remote',
scope: this
})] // Form items closure
});
this.buttons = [new Prg.btn({
text: btnUploadMsg,
handler: this.onSave,
scope: this
}), new Prg.btn({
text: btnCancelMsg,
handler: function() {
this.hide();
},
scope: this
})];
this.callParent(arguments);
this.form = this.getComponent('blog-edit-form').getForm(); // 'upload-form-'+this.filetype
}
});
Hope this helps.
Maybe you can use a Resizer?
Here are some examples.
I am trying to add a toolbar into my already created layout. I have the codes for both the toolbar and layout but i dont know how to integrate the the too
For my toolbar
<script>
Ext.onReady(function () {
new Ext.Toolbar({renderTo: Ext.getBody(),
items: [{
xtype: 'button',
text: 'Menu Button',
menu: [{
text: 'Better'
}, {
text: 'Good'
}, {
text: 'Best'
}]
},'->', {
xtype: 'splitbutton',
text: 'Split Button',
menu: [{
text: 'Item One'
}, {
text: 'Item Two'
}, {
text: 'Item Three'
}]
},'', {
xtype: 'cycle',
showText: true,
minWidth: 100,
prependText: 'Quality: ',
items: [{
text: 'High',
checked: true
}, {
text: 'Medium'
}, {
text: 'Low'
}]
},]
});
});
</script>
and for my layout, I have
<script>
var viewport = new Ext.Viewport({
layout: "border",
defaults: {
bodyStyle: 'padding:10px;',
},
items: [{
region: "north",
html: 'North',
margins: '5 5 5 5'
}, {
region: 'west',
collapsible: true,
title: 'Some Info',
width: 200,
html: 'West',
margins: '0 0 0 5'
}, {
region: 'center',
title: 'Our Info',
html: 'Center',
margins: '0 0 0 0'
}, {
region: 'east',
collapsible: true,
width: 200,
title: 'Their Info',
html: 'East',
margins: '0 5 0 0'
}, {
region: 'south',
title: 'Their Info',
html: 'South',
width: 200,
margins: '5 5 5 5'
}]
});
</script>
How can i use the toolbar on this page?
Thanks
#Justin, Here is my full code
var viewport = new Ext.Viewport({
layout: "border",
tbar: new Ext.Toolbar({
//Toolbar config options
items: [{
xtype: 'button',
height: 27,
text: 'Menu Button',
menu: [{
text: 'Better'
}, {
text: 'Good'
}, {
text: 'Best'
}]
}, '->',
{
xtype: 'splitbutton',
text: 'Split Button',
menu: [{
text: 'Item One'
}, {
text: 'Item Two'
}, {
text: 'Item Three'
}]
}, '',
{
xtype: 'cycle',
showText: true,
minWidth: 100,
prependText: 'Quality: ',
items: [{
text: 'High',
checked: true
}, {
text: 'Medium'
}, {
text: 'Low'
}]
}, ]
}),
defaults: {
bodyStyle: 'padding:10px;',
},
//layouf config
tems: [{
region: "north",
html: 'North',
margins: '5 5 5 5'
}, {
region: 'west',
collapsible: true,
title: 'Some Info',
width: 200,
html: 'West',
margins: '0 0 0 5'
}, {
region: 'center',
title: 'Our Info',
html: 'Center',
margins: '0 0 0 0'
}, {
region: 'east',
collapsible: true,
width: 200,
title: 'Their Info',
html: 'East',
margins: '0 5 0 0'
}, {
region: 'south',
title: 'Their Info',
html: 'South',
width: 200,
margins: '5 5 5 5'
}]
});
You should be able to add your toolbar as a config option to the bbar or tbar of your main panel.
var viewport = new Ext.Viewport({
layout: "fit",
items: [
//We add one "main" panel that fills up entire Viewport
{
layout: "border",
defaults: {
bodyStyle: 'padding:10px;',
},
tbar: new Ext.Toolbar({
//your Toolbar config options
}),
items: [
//your panels here
]
}
]
...
In this scenario, you would want to get rid of the "renderTo" config in your toolbar.
Sencha Touch n00b here. I'm trying to make a form with a tabpanel within a tabpanel. They work ok, but the outer tabpanel has a huge indent (or left/top margin or something), and so does the inner tabpanel.
I've tried every single layout/margin/border/padding/flex/align option in existence, and nothing makes any difference!
code (redundant overkill options left in):
MyApp.views.pendingDetails = new Ext.form.FormPanel({
id: 'pendingDetails',
padding: 0,
margin: 0,
layout: 'auto',
align: 'stretch',
items: [{
height: 500,
xtype: 'tabpanel',
activeTab: 0,
//width: 400,
tabBar: { //pack: 'center', // this will center the menu,
cls: 'MainTabHeader',
padding: 0,
margin: 0
},
padding: 0,
layout: 'auto',
border: false,
margin: 0,
align: 'stretch',
layout: 'auto',
items: [{
xtype: 'tabpanel',
border: true,
title: 'Customer',
activeTab: 0,
padding: 0,
border: false,
margin: 0,
height: 300,
align: 'stretch',
layout: 'auto',
tabBar: { //pack: 'center', // this will center the menu,
cls: 'SubTabHeader',
padding: 0,
margin: 0
},
items: [{
xtype: 'panel',
title: 'Site',
border: true,
padding: 0,
items: [{
xtype: 'textfield',
name: 'StJobId',
cls: "detailText",
readOnly: true,
label: 'Job #'
}, {
xtype: 'textfield',
name: 'Priority',
readOnly: true,
cls: "detailText",
label: 'Priority'
}, {
xtype: 'textfield',
id: 'txtAddress',
cls: "detailText",
readOnly: true,
label: 'Address'
}, {
xtype: 'textfield',
id: 'txtSuburb',
readOnly: true,
cls: "detailText",
label: 'Suburb'
}, {
xtype: 'textfield',
name: 'Company',
readOnly: true,
cls: "detailText",
label: 'Company'
}]
}, {
xtype: 'panel',
border: true,
title: 'Contacts'
}, {
xtype: 'panel',
border: true,
title: 'Security'
}]
}, {
xtype: 'panel',
border: true,
title: 'Install',
height: 300,
items: [{
xtype: 'button',
text: 'Install tab',
iconCls: 'jobrequests',
iconMask: true,
iconAlign: 'top',
ui: 'plain',
cls: "TBButton"
}]
}, {
xtype: 'panel',
border: true,
title: 'History'
}]
}],
dockedItems: [
MyApp.views.pendingDetailsTopToolbar]
});
It renders as:
How do I get rid of the indents marked in red?
Apparently FormPanels were designed for basic CRUD. They can't handle having tabpanels as items.
I changed the FormPanel to a Panel, handled the data manually, and it now renders fine.