Adding a image in ext tab panel - extjs

I am new to ext js.How do i add an image as a logo of my application in the header of ext tab panel?
Following is my code:-
Ext.define('MyApp.view.main.Main', {
extend: 'Ext.tab.Panel',
xtype: 'app-main',
requires: [
'MyApp.view.main.MainController',
'MyApp.view.main.MainModel',
'MyApp.view.main.List'
],
controller: 'main',
viewModel: 'main',
defaults: {
styleHtmlContent: true
},
tabBarPosition: 'bottom',
items: [
{
title: 'Home',
iconCls: 'fa-home',
layout: 'fit',
items: [{
xtype: 'mainlist'
}]
}
]
});
I need to add a logo in place of 'myapp' which is appearing as title. I want it something like the below image:-

To Answer this I created a new app in Extjs6 and did some modification which is below to get the logo.
Place the image and css in your resource folder then add below css in your css file.
.my-logo-icon {
background-image: url(../images/newpowered.gif) !important;
}
then place css path in app.json to get the css.
{
"path": "resources/css/styles.css"
}
Now in your code call this css at iconCls
iconCls: 'my-logo-icon'
complete code is
Ext.define('MyApp.view.main.Main', {
extend: 'Ext.tab.Panel',
xtype: 'app-main',
requires: [
'Ext.plugin.Viewport',
'Ext.window.MessageBox',
'MyApp.view.main.MainController',
'MyApp.view.main.MainModel',
'MyApp.view.main.List'
],
controller: 'main',
viewModel: 'main',
ui: 'navigation',
tabBarHeaderPosition: 1,
titleRotation: 0,
tabRotation: 0,
header: {
layout: {
align: 'stretchmax'
},
title: {
flex: 0
},
iconCls: 'my-logo-icon'
},
tabBar: {
flex: 1,
layout: {
align: 'stretch',
overflowHandler: 'none'
}
},
responsiveConfig: {
tall: {
headerPosition: 'top'
},
wide: {
headerPosition: 'left'
}
},
defaults: {
bodyPadding: 20,
tabConfig: {
plugins: 'responsive',
responsiveConfig: {
wide: {
iconAlign: 'left',
textAlign: 'left'
},
tall: {
iconAlign: 'top',
textAlign: 'center',
width: 120
}
}
}
},
items: [{
title: 'Home',
iconCls: 'fa-home',
// The following grid shares a store with the classic version's grid as well!
items: [{
xtype: 'mainlist'
}]
}, {
title: 'Users',
iconCls: 'fa-user',
bind: {
html: '{loremIpsum}'
}
}, {
title: 'Groups',
iconCls: 'fa-users',
bind: {
html: '{loremIpsum}'
}
}, {
title: 'Settings',
iconCls: 'fa-cog',
bind: {
html: '{loremIpsum}'
}
}]});
And out put image is

You can also do it like this:
items : [{
title : "<img src='../resources/images/whatever.png'>",
xtype : 'home-page',
bodyCls : 'menu-tabs' // optional
}, {
}]
and if you want the tab to be a little taller just use this as css
div[class~="menu-tabs"] div[class~="x-box-scroller-body-vertical"] div[class~="x-box-target"] a[class~="x-tab-default"] span[class~="x-tab-wrap-default"] span[class~="x-tab-button-default"]{
height: 50px;
}

Related

face to white mark after folding the panel EXTJS

I have button on the first item of carousel on the Main View.
Button is managed by ButtonController and opens Form.
This form have tools: close, hide. When I click on close or hide tool on the forms after, for example closing I see white artifact. This looks like mark of header of Form..
enter image description here
Maybe this can be decided by trivial action?
Thanks
UPD: some code.
part of controller:
Ext.define('Foresto.view.main.ButtonController', {
extend: 'Ext.app.ViewController',
alias: 'controller.comenuform',
layout: 'vbox',
requires: [
'Foresto.view.forms.1',
'Foresto.view.forms.2',
'Foresto.view.forms.3',
'Foresto.view.forms.4'
],
views: ['Foresto.view.main.Main'],
cutForms: function () {
Ext.create('Ext.panel.Panel', {
layout: 'fit',
renderTo: 'mainPart',
autoshow: true,
items: [{
xtype: 'formsType4'
}]
})
},
part of form:
Ext.define('Foresto.view.forms.Formf', {
extend: 'Ext.form.Panel',
title: 'testApp',
header: {
cls: 'header-cls',
},
tools: [
{type: 'minimize',
handler: function(){
this.up("panel").hide();
}},
{type: 'save'},
{type:'close',
handler: function(){
this.up("panel").close();
}},
],
xtype: 'formsType4',
url: 'save-form.php',
defaults: {
xtype: 'selectfield',
labelWrap: true,
afterLabelTextTpl: [
'<span style="color:red;font-weight:normal" data-qtip="Required">*</span>'
]
},
items: [{...
and code of main:
Ext.define('Foresto.view.main.Main', {
extend: 'Ext.form.Panel',
id:'control-panel',
xtype: 'app-main',
controller:'comenuform',
requires: [
'Foresto.view.map.Map',
'Foresto.view.main.ButtonController',
],
padding: 0,
id:"bighBox",
header: {
cls: 'header-cls',
title : {
cls : 'header-title-cls',
text : 'MyApp'
}
},
tools: [{
type: 'menu',
handler: function(me) {
var cp = me.down('panel');
if (cp._hidden)
cp.show(true);
else
cp.hide(true);
}
}],
items:[{
xtype: 'carousel',
id: "mainPart",
flex: 1,
defaults: {
border: true,
ui: 'light'
},
items: [{
layout: {
type: 'vbox',
align: 'middle',
pack: 'center'
},
cls: 'colorful2',
defaults: {
border: true,
ui: 'light',
flex: 1
},
items:[{
xtype:'button',
cls: 'button-cls',
text: 'buttonOfForm4',
id: "RenterId",
margin: 10,
width: 920,
height: 250,
length: 150,
handler: 'renterForms'
... (some other buttons, which call forms too)..

Displaying a grid inside the viewport on click - Ext JS

What I'm trying to do is add a grid that is 65% width of the panel created in my app.js
Ext.application({
name: 'AM',
appFolder: 'app',
controllers: [ 'Metadata', 'Print', 'Export' ],
launch: function() {
var types = Ext.create('AM.store.Type');
Ext.create('Ext.panel.Panel', {
renderTo: Ext.getBody(),
width: 1000,
height: 600,
title: '<center>MetaCenter</center>',
layout: 'hbox',
style: { marginLeft: 'auto', marginRight: 'auto' },
items: [
{ xtype: 'panel', padding: 5, height: 500, width: '35%',
items: [
...
{ xtype: 'button', text: 'Search',
listeners: {
click: function() {
console.log('Search Button clicked');
//Code to create panel view?
}
},
],
}
I'm not explicitly creating a viewport, so I don't believe I could do a viewport.add('grid') function, but I'm not sure. Any ideas?
You could add the grid when creating the container, with hidden: true, then show it when the button is clicked:
{
layout: {
type: 'hbox',
align: 'stretch'
},
items: [
{
xtype: 'panel',
flex: 0.35,
items: [
...
{
xtype: 'button',
text: 'Search',
listeners: {
click: function(btn) {
btn.up('panel').nextSibling().show();
}
}
}
]
},
{
xtype: 'grid',
flex: 0.65,
hidden: true,
...
}
]
}

Layer button xtypes on top of img xtypes in Sencha Touch 2

I'm trying to put 3 buttons on top of an xtype:'img', but I'm getting nowhere and can't find much online about it.
How does this work?
EDIT:
i have an image and when you tap it i want it to display the same image but now there are 3 options you can choose from view download share i want the buttons to look like they pop up over the image
Ext.define('Crystal.view.apphb',{
extend: 'Ext.Panel',
xtype:'apphb',
id:'panel',
requires: [
'Ext.TitleBar',
],
config:{
layout: {
type: 'card',
animation: {
type: 'fade'},
},
items:[{
xtype:'img',
src:'resources/img/apphb.png',
listeners: {
tap: function() {
Ext.getCmp('panel').setActiveItem(1);
},
},
},
{
xtype:'img',
src:'resources/img/1.png',
listeners: {
tap: function() {
Ext.getCmp('panel').setActiveItem(-1);
}
},
}
]
}
});
What I understand from your question is simple. You want to show certain buttons in a pop up on tap of image. So you use overlays and put buttons inside it.
A working fiddle with demo is here. You can display anything in you want in this pop up.
The method .showBy() let you place pop up relative to certain element passed as parameter. Here's the code,
launch: function() {
Ext.create('Ext.Panel', {
fullscreen: true,
items:[
{
xtype:'image',
src: 'http://www.sencha.com/assets/images/sencha-avatar-64x64.png',
height: 64,
width: 64,
listeners:{
tap:function( img,e,opts ){
var overlay = Ext.Viewport.add({
xtype: 'panel',
left: 0,
top: 0,
modal: true,
hideOnMaskTap: true,
hidden: true,
width:160,
height:90,
items:[
{
xtype:'button',
text:'Download'
}
],
styleHtmlContent: true,
scrollable: true
});
overlay.showBy(img);
}
}
}
]
});
}
what about using img as the background for the container?
xtype: 'container',
style: 'background: url(http://wallpapers.free-review.net/wallpapers/36/New_Batman_movie.jpg) no-repeat;',
layout: {
align: 'stretch',
type: 'vbox'
},
items: [
{
xtype: 'container',
flex: 1
},
{
xtype: 'container',
height: 100,
defaults: {
margin: 5,
height: 80,
width: 100
},
items: [
{
xtype: 'button',
text: 'Like'
},
{
xtype: 'button',
text: 'Tweet'
}
]
}
]
}

Adding carousel to panel

First program logic:
I have a main panel and there is a list at the left side and another panel at the right side.
When user touches the list item some html appears in right panel. What i need to do is using carousel instead of right panel.
My view
Ext.define('MyApp.view.MyPanel', {
extend: 'Ext.Panel',
xtype:'mypanel',
config: {
ui: 'dark',
layout: {
type: 'card'
},
items: [
{
xtype: 'titlebar',
docked: 'top',
title: 'Lezzet Dunyasi',
},
{
xtype: 'list',
docked: 'left',
id: 'mylist',
ui: 'round',
pinHeaders: false,
grouped: true,
//disableSelection: true,
width: 331,
itemTpl: [
'<img src="{img_url}" width="60" heigh="60"></img><span>{label}</span>'
],
store: 'Menius',
items: [
{
xtype: 'searchfield',
docked: 'top',
placeHolder: 'Search...',
},
]
},
{
xtype: 'panel',
styleHtmlContent:true,
style: {
backgroundImage: 'url(resources/img/Landscape.png)',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center'
},
id:'mypanel'
}
]
}
});
As you can see there is a xtype:panel and i tried to modify that code and i did it like this
xtype: 'carousel',
defaults{
styleHtmlContent:true,
id:'mypanel'},
items: [
{
html : 'Item 1',
style: 'background-color: #5E99CC'
},
{
html : 'Item 2',
style: 'background-color: #759E60'
},
{
html : 'Item 3'
}
]
Also i use a controller
Ext.define('MyApp.controller.MeniuController',{
extend:'Ext.app.Controller',
config:{
refs:{
leftMeniu:'mypanel list[id=mylist]',
myPanel:'mypanel panel[id=mypanel]'
},
control:{
leftMeniu:{
itemtap:'onItemTap'
}
}
},
onItemTap:function(list, index, item, record, e , opts)
{
var content = '<h2>' + record.get('label') +'</h2>' + record.get('html');
this.getMyPanel().setHtml( content );
}
});
And i modified this part like this
refs:{
leftMeniu:'mypanel list[id=mylist]',
myPanel:'mypanel carousel[id=mypanel]'
Although these modifications i can't run my code , what should i do ?
A couple of small issues that I see. You are missing a colon on defaults: And I think you want to move that id to one of your carousel elements, right? With your code, I'm only getting one page with the id defined at that level. If you move it down you will see three pages.
defaults: {
styleHtmlContent:true,
id:'mypanel' // IN WRONG PLACE?
},
[UPDATE]
I got it working so that you can write to any of your carousel panels. I just created a direct reference to each id in the refs:{} section. I'm drawing to the second page so drag it into view to see the updates.
Also, I'm adding the model, store, and app.js so that anyone reading this will have a complete working example.
Ext.define('MyApp.controller.MeniuController', {
extend:'Ext.app.Controller',
config:{
refs:{
leftMeniu:'mypanel list[id=mylist]',
// myPanel:'mypanel panel[id=mypanel]'
// myPanel:'mypanel carousel[id=mypanel]'
myFirstPanel:'#mypanel1',
mySecondPanel:'#mypanel2'
},
control:{
leftMeniu:{
itemtap:'onItemTap'
}
}
},
onItemTap:function(list, index, item, record, e, opts) {
var content = '<h2>' + record.get('label') + '</h2>' + record.get('html');
this.getMySecondPanel().setHtml(content);
this.getMyFirstPanel().setHtml(content);
}
});
Complete MyPanel View:
Ext.define('MyApp.view.MyPanel', {
extend: 'Ext.Panel',
xtype:'mypanel',
config: {
ui: 'dark',
layout: {
type: 'card'
},
items: [
{
xtype: 'titlebar',
docked: 'top',
title: 'Lezzet Dunyasi'
},
{
xtype: 'list',
docked: 'left',
id: 'mylist',
ui: 'round',
pinHeaders: false,
// grouped: true,
//disableSelection: true,
width: 331,
itemTpl: [
'{label}'
],
store: 'Menius',
items: [
{
xtype: 'searchfield',
docked: 'top',
placeHolder: 'Search...'
}
]
},
// {
// xtype: 'panel',
// styleHtmlContent:true,
// style: {
// backgroundImage: 'url(../images/risk2.png)',
// backgroundRepeat: 'no-repeat',
// backgroundPosition: 'center'
// },
// id:'mypanel'
// }
{
xtype: 'carousel',
defaults: {
styleHtmlContent:true
},
items: [
{
html: 'Item 1',
style: 'background-color: #5E99CC',
id:'mypanel1'
},
{
html: 'Item 2',
style: 'background-color: #759E60',
id:'mypanel2'
},
{
html: 'Item 3'
}
]
}
]
}
});
app.js
Ext.application({
name: "MyApp",
views: ['MyPanel'],
models: ['Meniu'],
stores: ['Menius'],
controllers: ['MeniuController'],
launch: function() {
Ext.Viewport.add(Ext.create('MyApp.view.MyPanel'));
}
});
Model:
Ext.define('MyApp.model.Meniu', {
extend: 'Ext.data.Model',
config: {
fields: ['img_url', 'label', 'html']
}
});
Store:
Ext.define('MyApp.store.Menius', {
extend: 'Ext.data.TreeStore',
config: {
model: 'MyApp.model.Meniu',
defaultRootProperty: 'items',
grouper: function(record) {
return record.get('label')[0];
},
root: {
text: 'foo',
items: [
{img_url: 'foo.png', label: 'one', html:'nice', leaf: true},
{img_url: 'foo.png', label: 'two', html:'carousels', leaf: true}
]
}
}
});

Sencha Touch 2: Trying to add a list to a panel

I have a panel which consists of a toolbar and tabs. On each tab there should be a list and a button. I believe I have this set up correctly except for the list, which I am trying to add as follows:
Ext.define('Myapp.view.Search', {
xtype: 'search',
extend: 'Ext.tab.Panel',
config: {
activeItem: 0,
tabBar: {
docked: 'top',
autoScroll: 'auto',
ui: 'light',
layout: {
pack: 'center'
}
},
items: [
{
xtype:'toolbar',
docked:'top',
ui: 'light',
title: 'Search'
},
{
title: 'Tab 1',
xtype: 'formpanel',
items: [
{
xtype: 'Mylist' //DOES NOT WORK
},
{
xtype: 'panel',
defaults: {
xtype: 'button',
style: 'margin: 0.1em',
flex : 1
},
layout: {
type: 'hbox'
},
items: [
{
text: 'Button 1',
}
]
}
]
},
{
title: 'Tab 2',
xtype: 'formpanel',
items: [
{
xtype: 'panel',
defaults: {
xtype: 'button',
style: 'margin: 0.1em',
flex : 1
},
layout: {
type: 'hbox'
},
items: [
{
text: 'Button 1',
}
]
}
]
}
]
}
});
Please let me know what I am doing wrong and thanks for you help!
EDIT: added Mylist below:
Ext.define('Myapp.view.Mylist', {
extend: 'Ext.dataview.NestedList',
xtype: 'Mylist',
config: {
store: 'Sections'
},
getTitleTextTpl: function() {
return '{name}';
},
getItemTextTpl: function(node) {
return '<strong>{name}</strong>';
},
});
Try these
in View:
{
xtype: 'panel',
flex: 4,
width: '400px',
height:"700px",
layout: {
type: 'fit'
},
items: [
{
xtype: 'list',
// loadingText:"Loading Category",
styleHtmlContent: true,
// id:"mylist2",
width:"300px",
itemTpl:
'<div class="mycon">'+
'<input type="image" id="click" img src="{coupon_image}" style="max-width:130%;border:6px double #000000;" width="200" height="200"' +'style="padding:3px;">' +
'</div>'+
'<div><font size="2" color="red"><b>Coupon Name:</b></font></div>'+
'<div><font size="2" color="green"><b>{coupon_name}</b></font></div>'+
'</div>',
store : 'ViewCategoryStore',
},
]
}
in controller:
Ext.define('Expressdeal.controller.ViewCategoryController', {
extend: 'Ext.app.Controller',
config: {
refs: {
viewcat : 'viewcategory' // xtype of the view
},
control: {
'viewcategory list: {
activate: 'onActivate',
itemtap: 'onItemTap',
},
Where you define your list in your List view you should say
alias:'widget.Mylist'
instead of
xtype:'Mylist'
also your list needs an itemTpl config im pretty sure.
config: {
store: 'Sections',
itemTpl:'{example}'
}
And as long as the store that drives your list is in working shape the list should appear correctly

Resources