I have an item inside a container in my Viewport, I want to copy that item to a new window: What I've tried copies the item to the new window but unfortunately it destroys it in the container.
How can I keep it in both places ?
onOpenNewClick: function () {
var win;
var viewport = this.getMyViewport();
var chart = viewport.down('container #thechart');
win = Ext.create('widget.window', {
title: 'Layout Window',
width: 1000,
height: 600,
constrain: true,
constrainHeader: true,
hidden: false,
shadow: false,
maximizable: true,
autoScroll: true,
title: 'test',
layout: 'fit',
items: [{
region: 'center',
layout: 'fit',
title: 'chart',
xtype: chart
}]
});
win.show()
win.center();
},
My viewport :
items: [{
region : 'center',
height : '100%',
items : [{
xtype : 'container',
id : 'pan_chart',
border : false,
autoHeight : true,
hidden : true,
autoScroll : true,
items : [{
width : screen.width,
xtype: 'mychart',
id : 'thechart',
}]
}]
}
]
You need to clone the object instead of copying. Because when you copy you copy the reference and not creating a new instance of the object.
This thread discusses cloning of ExtJs objects.
Edit:
You are getting an extjs object and store it in the chart variable. In the second part you are trying to assign the object to the xtype property.
You should directly add it to the items property like so:
win = Ext.create('widget.window', {
title: 'Layout Window',
layout: 'fit',
items: [chart]
});
But this still "cut" your object and not "copy" it.
Edit2:
A good way for component copying is creating a function that return an instance of a chart. You can use the same store with the same data.
function createChart(store){
return Ext.create('Ext.chart.Chart', {
width: 400,
height: 300,
store: store
});
}
use it like so:
win = Ext.create('widget.window', {
title: 'Layout Window',
layout: 'fit',
items: [createChart(myStore)]//myStore must be defined
});
Related
I am reading data from store and populating main girdView. When any of the row is clicked, a windows appear and I want to fill the fieldset in that window with the same record which is clicked.
Can anyone tell me how to do it?
My popup window is like:
{
extend: 'Ext.window.Window',
height: 500,
width: 1500,
minWidth :1500,
maxWidth :1500,
layout: 'fit',
controller: 'PopUpWindowController',
initComponent: function () {
var me = this;
//console.log(me.myExtraParams);
var Store = Ext.getStore('mainStore');
Ext.applyIf(me, {
/* items: [{
xtype: 'form',
bodyPadding: 10,
region: 'center'
}]*/
});
me.callParent(arguments);
},
items: [
{
xtype: 'panel',
title : 'Projektierung',
bodyStyle : 'padding:5px',
width : 1880,
autoHeight : true,
items:
[
{
xtype : 'kopfdatenView', // Have to populate this view
}
]
}]}
and in Main view I am calling it as:
{
region: 'center',
xtype: 'gridpanel',
listeners : {
itemdblclick: function(dv, record, item, index, e) {
var extra = record.data;
win = Ext.create('App.view.PopUpWindow');
console.log(win.myExtraParams);
win.on('show', function(win) {
win.setTitle(record.get('ID'));
});
win.show();
}
},
columns: [
****
],
store: 'mainStore',
height: 100,
width: 400,
}
I want to populate fieldset in kopfdatenView. Kindly help
You directly pass your record to your window on creation :
win = Ext.create('App.view.PopUpWindow', {
myRecord: record
});
And then inside the window's initComponent function (before the callParent) :
this.title = this.myRecord.get('ID');
You can do something like this:
win = Ext.create('App.view.PopUpWindow', {
params: record
});
Then, in your PopUpWindowController you can retrieve 'params' in the render event (for example).
I need to resize my popup created by using Ext.Window based on the controls render on it.
I popup an aspx page and dynamically creating control on it. So i can't hard code the height of the window.
How can I resize the popup window height. Please help me with your valueable information.
My code is as follows.
Ext.onReady(function () {
var myWin = new Ext.Window({
title: 'Add to Favourit',
width: 380,
height: 300,
closable: true,
buttonAlign: 'center',
items: [{
xtype: 'panel',
layout: {
type: 'hbox',
align: 'stretch'
},
items: [{
xtype: 'box',
itemId: 'iFrameInWindow',
title: 'IFrame',
autoEl: {
tag: 'iframe',
src: 'forms/test.aspx?id=1'
},
flex: 1,
width: 380,
height: 300,
}],
listeners: {
afterrender: function () {
//
},
}
}]
});
myWin.show();
});
Thanks in advance.
I've been digging my mind all this morning to find the solution to this, I have an Extjs window where I want to put a chart as an item. I'm using Extjs 4, here's my window :
Ext.define('Metrics.view.ChartWin', {
extend: ['Ext.window.Window'],
alias: 'widget.chartwin',
requires :['Ext.chart.*','Ext.Window', 'Ext.fx.target.Sprite', 'Ext.layout.container.Fit', 'Ext.window.MessageBox', 'Metrics.view.DrawChart'],
width: 800,
height: 600,
minHeight: 400,
minWidth: 550,
hidden: false,
shadow: false,
maximizable: true,
title: 'Area Chart',
renderTo: Ext.getBody(),
layout: 'fit',
tbar: [{
text: 'Save Chart',
handler: function() {
Ext.MessageBox.confirm('Confirm Download', 'Would you like to download the chart as an image?', function(choice){
if(choice == 'yes'){
chart.save({
type: 'image/png'
});
}
});
}
}],
items:[{
//I guess the problem comes from here??
xtype : 'drawchart'
}]
});
My chart :
Ext.define('Metrics.view.DrawChart', {
extend: 'Ext.chart.Chart',
alias: 'widget.drawchart',
requires: ['Ext.chart.*'],
renderTo: Ext.getBody(),
width: 700,
height: 600,
animate: true,
store: 'GraphData',
shadow : true,
legend: {
position: 'right'
},
axes: [
{
title: 'Week',
type: 'Numeric',
position: 'left',
fields: ['Week'],
grid : true
},
{
title: 'In Out Backlog',
type: 'Numeric',
position: 'bottom',
fields: ['BL1 Alt']
}
],
theme: 'Red',
series: [
{
//BLA BLA BLA
}]
});
My chart works fine. Now please tell me, how do I add this chart to my window ? I get this error message :
Cannot read property 'isInstance' of undefined
Thank you.
Remove
renderTo: Ext.getBody()
from your chart definition. The Chart should be rendered in the window.
Then instantiate a window and set the chart as an item there:
Ext.create('Ext.window.Window', {
...
items: [{
xtype: 'drawchart'
}]
...
Look at the code here: http://jsfiddle.net/AMx6r/1282/
I use extjs4.1 with geoext2 in my web app.
I want to load mapPanel to tabPanel via ajax and it fill tabPanel height and width.
If i set mapPanel height and width i can see it in tabPanel but it can't fill tabPanel because i set it height and width.Following code:
mapPanel = Ext.create("GeoExt.panel.Map", {
renderTo: "mappanel",
height: 575,
width: 1124,
map:map,
zoom: 11,
tbar : toolbar
});
var tabs = Ext.create('Ext.tab.Panel', {
region: 'center', // a center region is ALWAYS required for border layout
deferredRender: false,
activeTab: 0, // first tab initially active
items: [{
title: 'History',
autoScroll: true
}, {
title: 'Center Panel',
autoScroll: true
}]
});
I insert MapPanel to tabPanel when user click on grid column that has icon via following code.
var grid = Ext.create('Ext.grid.Panel', {
store: store,
columnLines: true,
columns: [
{
menuDisabled: true,
sortable: false,
xtype: 'actioncolumn',
width: 20,
items: [{
icon : '<?php echo Yii::app()->baseUrl.'/images/icons/show.png';?>',
tooltip: 'Show Map',
handler: function(grid, rowIndex, colIndex) {
var rec = store.getAt(rowIndex);
var jsonData = Ext.encode(store.proxy.reader.jsonData);
tabs.remove(tabs.getComponent(2));
tabs.insert(2,{
title:'Map',
layout: 'fit',
loader: {
scripts: true,
autoLoad :true,
params:{
history:jsonData,
index:rowIndex
},
failure : function(){
alert('failed');
},
url: '<?php echo Yii::app()->createUrl('MapWidget/HistoryMap');?>'
}
});
tabs.setActiveTab(2);
tabs.doLayout();
}
}]
},
...
But when i clean height and width in mapPanel options i can't see it in tabPanel!
How can i load mapPanel to tabPanel to fill it's content?
From the docs
Do not use this option if the Component is to be a child item of a
Container. It is the responsibility of the Container's layout manager
to render and manage its child items.
Here's some example code for loading components remotely in the correct way: http://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/component-loader/component-loader.html
I'm writing an app where I have a BorderLayout for the entire page. In the south part I have a Panel to which I add FormPanels. I would like to be able to scroll that Panel so I can scroll through the FormPanels.
So far, nothing I've found from searches has helped. I don't quite understand what ExtJS requires in terms of the combination of LayoutManagers, setting the size and setting AutoScroll.
Any partial tips will be gratefully followed up.
A code snippet:
new Ext.Viewport({
layout: "border",
items: [{
region: "north",
contentEl: "title",
height: 50
}, {
region: "center",
id: "mappanel",
title: "Map",
xtype: "gx_mappanel",
map: map,
layers: [layer],
extent: extent,
split: true,
tbar: toolbarItems
}, {
region: "east",
title: "Details",
width: 300,
split: true,
id: "east-panel",
laout: 'fit'
}, {
region: "south",
id: "south-panel",
height: 200
}, {
region: "west",
id: "west-panel",
width: 300
}]
});
matchedTrailJunctionsPanel = new Ext.Panel({
title: "Matched Trail Junctions2",
id: "matched-trail-junctions",
autoScroll:true
//layout: 'anchor'
});
var southPanel = Ext.getCmp('south-panel');
southPanel.add(matchedTrailJunctionsPanel);
southPanel.doLayout();
createTrailJunctionPanel = function(trailJunction) {
var trailJunctionPanel = new Ext.form.FormPanel({
labelWidth: 75,
width: 350,
defaultType: 'textfield',
items: [{
fieldLabel: 'Junction Name',
name: 'junction-name'
}],
autoScroll:true,
//anchor: '100% 100%',
height: 100
});
matchedTrailJunctionsPanel.add(trailJunctionPanel);
if(trailJunction.publicTrailSegments.length == 0) {
matchedTrailJunctionsPanel.add(new Ext.form.Label({text: 'No public trails matched'}));
} else {
var grid = new Ext.grid.GridPanel({
store: mapMatchObjectStore,
columns: [
{id:'publicTrailSegment',header: 'Trail', width: 160, sortable: true, dataIndex: 'publicTrailSegment'}
],
stripeRows: true,
autoExpandColumn: 'publicTrailSegment',
height: 350,
width: 600,
title: 'Matched Trail Junctions'
});
matchedTrailJunctionsPanel.add(grid);
}
matchedTrailJunctionsPanel.doLayout();
}
Your south panel is the main container for your components, so it should be autoScroll:true and you should be adding both your form and grid into it. You can't really add a grid into a FormPanel directly as it's not a form field (you'd have to wrap it as a Field or implement some of Field's interface). It may work with south having no layout (the browser should just stick the grid directly after the form) but generally it's better to specify an appropriate layout (vbox would be a good one in this case).
The containing panel must have the height set. The contained panels must either have the height set or autoHeight: true set.