Extjs-Window collpased:true not working - extjs

I have a window with a grid in it, i want to open the window collapsed. but even if i give collapsed:true it dont seem to work...here is my code
var gridWindow = new Ext.Window({
title : title,
iconCls:'diagramIcon',
id :id ,
layout:'fit',
itemId:nodeId,
plain:true,
collapsible:true,
collapsed:true,
shadow:false,
constrain:true,
animCollapse:true,
closeAction:'close',
expandable:true,
items:[schemaGrid(nodeId,id)],
height: height,
width: width
})
can some one help.....

You need to set expandOnShow property as well. Add
expandOnShow: false,
to your window configurations. Alternatively you can also use the APIs. Display the grid window by:
gridWindow.show().collapse(false);
This will ensure that the window is collapsed when it is displayed.

Related

Custome MessageBox under Tab(s) ExtJs

I like to separate MessageBox tab to tab. One MessageBox will shown in one particular tab and will hidden from all other tab(s). What is now show as global in application. Is there any way to show message under every tab(s) in application.
You cannot use a messagebox with different content on the separate tabs at the same time while messagebox is a singleton, but you can create your own messagebox, extending from Window and render each instance to the separate tab. Here is example with native Window, but it will work the same with extended component.
You cannot directly use Ext.window.MessageBox to achieve what you want. On the other hand, you can create a small utility class that extends Ext.window.Window, with a static function that makes it appear with the title, message, and buttons as parameters, and use the constrainTo option to make it belong to your tab.
This way, you have a window that can be "owned" by a tab instead of appearing globally
Here i create a function to show message as messagebox. And i can use it whatever i need.
ShowPrivateMessage: function(title, widthValue, heightValue, msgText, renderTabId){
Ext.create("Ext.window.Window",{
title : title,
width : widthValue,
height: heightValue,
html : '<span style="font-size: small">'+ msgText + '</span>',
renderTo: renderTabId,
resizable: false,
draggable: false,
bodyPadding: '10px',
listeners:{
afterrender: function(sender, eOpt){
var parentWindow = Ext.getCmp(renderTabId);
parentWindow.disable();
}
,close: {
fn:function(ctrl,opt){
var parentWindow = Ext.getCmp(renderTabId);
parentWindow.enable();
}
}
}
}).show();
}

how to increase the tabpanel height and width which is created in extjs?

I have a TabPanel, where the TabPanel contains two parts, one part has details about the image and the down part has the image which is created using Panel. Now the image is unreadable in IE8(less size), so i want to increase the size of the Imagepanel in the Tabpanel. How can i achieve this?
Thanks,
Raj
var tabs = new Ext.TabPanel({
activeTab : 0,
autoScroll: true,
width:200,
height: 200,
items:[]
});

Set properties of extJs htmleditor

I have a text box and there is some text written on it. Now, when somebody clicks inside the text box, I open a html editor (http://docs.sencha.com/ext-js/3-4/#!/api/Ext.form.HtmlEditor) and now i want to place the text written inside the text box to come in the html editor so that user can edit it easily and save it. Similarly, when i open the html editor i want to update the value inside the color box and font-size and font-value in the html editor. Assume that i can fetch these values from the textbox. I tried googling it but could not found how to do this.
Ext.QuickTips.init(); // enable tooltips
new Ext.Panel({
renderTo: 'text-editor',
id: 'html-editor',
width: 440,
height: 100,
frame: true,
layout: 'fit',
items: [
{
xtype: 'htmleditor',
enableColors: true,
enableAlignments: true
}
]
});
$('#selected-text-box').click(function() {
showEditor(this.id);
//TODO: Write code here to set the properties of editor with the properties set in textbox
});
Now, i just want to ask. how to access the fields of html editor and set their value.
Try this, I will work but about font-size I don't know
var Content = $('#' + textBoxId).html();
editor.setValue(Content);
I have tried this. It works :)

Auto-size Ext JS Window based on content, up to maxHeight

Using Ext JS 4.0.2, I'm trying to open a window that automatically sizes itself big enough to fit its content, until it hits a height limit, at which point it stops getting bigger and shows a scroll bar.
Here's what I'm doing
Ext.create('widget.window', {
maxHeight: 300,
width: 250,
html: someReallyBigContent,
autoScroll: true,
autoShow: true
});
When the window is first rendered, it's sized big enough for the really big content--bigger than the maxHeight should allow. If I attempt to resize it, then snaps down to the maxHeight of 300px.
How do I constrain the window to its maxHeight when it's initially rendered?
I have exactly the same problem and for now I'm doing a litle dirty hack :)
this.on('afterrender', function() {
if (this.getHeight() > this.maxHeight) {
this.setHeight(this.maxHeight);
}
this.center();
}, this);
Depending on the content of the window, you must use the afterlayout event. Instead of using this.maxHeight, to use the whole viewport, use Ext.getBody().getViewSize().height or in vanilla JS use window.innerHeight.
This version will work even if the windows contains other components and not only huge html:
listeners: {afterlayout: function() {
var height = Ext.getBody().getViewSize().height;
if (this.getHeight() > height) {
this.setHeight(height);
}
this.center();
}}
This can be better :
bodyStyle: { maxHeight: '100px' }, autoScroll: true,
I don't see an out-of-the-box way to do this. However, you might try this approach:
Place the contents of the window into a container inside the window (i.e. make someReallyBigContent be inside a container.) On afterrender, get the height of that inner container and then proceed to set the height of the outer window based on that.
How I ended up displaying a window with an unknown amount of fields on a form (constrain = body.el):
prefForm.itemId = 'prefForm';
win = Ext.create('Ext.window.Window', {
layout : {
type : 'vbox',
align : 'center'
},
buttons : buttons,
maxHeight : constrain.dom.clientHeight - 50,
title : title,
items : prefForm,
listeners : {
afterrender : {
fn : function(win) {
var f = win.down('#prefForm');
f.doLayout();
var h = f.body.dom.scrollHeight;
if (f.getHeight() > h)
h = f.getHeight();
win.setHeight(h + 61);
win.center();
},
single : true
}
}
});
You can add this config on your window
maximizable: true
if you want you could programmatically 'click' that button :)
Now I see what you are trying to do. I think the only thing missing from your config is the height parameter. Set it to the same number as maxheight. That should do it, you won't need to call setHeight().
This is just like Ivan Novakov answer, except I prefer it when you override the onRender class for these types of classes.
This is for a couple of reasons. Removes an additional event listener, and in the case you have multiple things that need to occur at afterrender time. You can control the synchronization of these tasks.
onRender: function(ct,pos) {
//Call superclass
this.callParent(arguments);
if (this.getHeight() > this.maxHeight) {
this.setHeight(this.maxHeight);
}
this.center();
}
I had the little bit different problem. In my case ExtJS code there inside the HTML popup windows. And I had to achieve:
change the size of panel when we change the size of popup windows.
Ivan Novakov's solution worked for me.
Ext.EventManager.onWindowResize(function () {
var width = Ext.getBody().getViewSize().width - 20;
var height = Ext.getBody().getViewSize().height - 20;
myPanel.setSize(width, height);
});

extjs panel resize while window resizes

I have a panel with a "form" layout, containing several buttons. now I want to enable this panel resize according to window resizing. How can I get this done?
thanks.
Ext.EventManager.onWindowResize(function(w, h){
panel.doComponentLayout();
});
Assuming you have a Panel named 'panel' with some automatic sizing built in (e.g. height: "100%"). Otherwise, the new width and height of the window are passed into the anonymous function passed to onWindowResize().
As wrote #deniztt you should subscribe to EventManager class onWindows Resize Event.
It can be something like this:
Ext.EventManager.onWindowResize(function () {
var width = Ext.getBody().getViewSize().width - 160;
var height = Ext.getBody().getViewSize().height - 140;
panel.setSize(width, height);
});
Where panel is reference to your panel
You can read about it here.
You can make the panel resizable by setting the 'resizable' config option, see the docs for the various options: http://dev.sencha.com/deploy/ext-4.0.0/docs/api/Ext.panel.Panel.html.
As far as how the form components interact you'll need to set anchor's if you want to use a form layout or switch to an hbox/vbox type of set-up with various flex settings.
You can set the size for window and set the child panel's autoHeight and autoWidth attributes true.
Another way is catching the resize event of the window and resize the child panel according to the new size values.
Thanks to Gegory and Joseph for the EventManager solution. I've done some minor changes to this solution, replacing the getBody() with a DIV and setting an initial width/height of my chart (or any other component):
<div id="chart" style="overflow: hidden; position:absolute; width:100%; height:90%;"></div>
....
Ext.onReady(function() {
var renderDiv = Ext.get('chart_div');
var chart = Ext.create('Ext.chart.Chart', {
renderTo: renderDiv,
width: renderDiv.getWidth(),
height: renderDiv.getHeight() - 50,
...
});
Ext.EventManager.onWindowResize(function () {
var height = renderDiv.getHeight() -50;
var width = renderDiv.getWidth();
chart.setSize(width, height);
});
});
autoWidth and autoHeight don't seem to work for me (Ext-JS 4.2.1).

Resources