I use rowwidget to display extra data for every row in my grid, for example: panel, but when I resize my grid or when the grid have a vertical scrollbar the size of the widget (width) remains the same, Is there any way to change the width of the widget automatically?
I mean like a layout for the rowwidget plugin?
config.plugins = [{
ptype: 'rowwidget',
widget: {
xtype: 'panel',
/* I want it's width as the plugin width even when resizing the grid*/
items: [],
height: 50,
style: {
'border': 'solid 1px green'
},
bind: {
}
}
}];
the layout can remain the same you can use the width of the grid, or window, to set a relative width for the widget dynamically . there should be a function that returns the width and height after onresize event, something like window.innerWidth , good luck finding the grid body with the console then get its width,
grid = Ext.getBody().component.items.items[1].items.items[1].body;
winWidth = grid.getWidth();
Related
I have a splibutton with a menu item. I want to make the width of the drop down equal to the split button width. Additionally I want to align the text in the center. How should I do it?
The width of the menu will be based on the width of the content inside. So if the width of the button will always be the same, you could set the width of the menu to that same value or you can get the width of the button and set it to the menu before rendering it.
As for centering the text, you have two options. Either via CSS, add a custom CLS to your menu and add the following CSS:
.yourCustomCls .x-menu-item-link {
text-align: center;
}
.yourCustomCls .x-menu-item-indent-no-separator {
margin-left: 0;
}
Or add the config plain: true to your menu and a style centering the text as in my example.
Example:
Ext.create('Ext.button.Split', {
renderTo: Ext.getBody(),
text: 'Commit Automatically',
menu: new Ext.menu.Menu({
plain: true,
style: 'text-align: center;',
items: [
{text: 'Commit On Trigger', handler: function(){ alert("Item 1 clicked"); }}
],
listeners: {
beforerender: function () {
this.setWidth(this.up('button').getWidth());
}
}
})
});
I use Ext JS. And I have a list of "panels". When user changes width of one panel, I need to change width of another panels automatically. Now when user changes one panel, another panels are not changed. Here is my code:
for (i = 0; i < resources.length; i++) {
table.add({
xtype: 'panel',
title: resources[i].name,
id: prefixResourceId + resources[i].id,
height: constHeight,
resizable:{
pinned:false,
dynamic:true,
floating:true
},
width: widthConst,
layout: 'fit'
});
}
I tryed to use this code:
listeners: {
resize: function(p) {
new Ext.Resizable(p.getEl(), {
pinned:false,
dynamic:true,
resizeElement: function() {
//this block works only when page are loaded
}
});
}
insdead of this:
resizable:{
pinned:false,
dynamic:true,
floating:true
},
But result is the same.
How can I change the width of all panels, when user changes width of one panel?
Put all the panels inside a surrounding panel, let the user change the size of this one, and all the contained panels will adapt their size automatically.
I have a simple Ext.ProgressBar and need to double it's height which works but didn't scale the progress image, just the outer box. I thought OK, maybee it is to small and can't scale but it has a height of >800px (sencha original images).
So how can this be done?
Here's the config
{
xtype: 'progressbar',
text: 'Some text',
border: 1,
height: 40
}
Height of progress bar is set in style definition. You can change height by changing .x-progress-bar css class. In modern browsers (eg. Chrome) all you need to do is to change height property, because background image is definied as gradient. Example:
// height of bar
.x-progress-bar {
height: 38px;
}
// height of text box
.x-progress-text {
height: 38px;
line-height: 38px;
}
Working sample: http://jsfiddle.net/D2QYN/2/
Another way is to attach handler to render event and set height of child elements which are not scaled verically. Example handler:
listeners: {
render: function(sender) {
var height = sender.bar.parent().getHeight(true); // content height
sender.bar.setStyle('height', height + 'px');
sender.textEl.setStyle('height', height + 'px');
sender.textEl.setStyle('line-height', height + 'px');
}
}
Working sample: http://jsfiddle.net/D2QYN/3/
If I have something like this:
var container = Ext.create('Ext.container.Container', {
plain:true,
width : 300,
height: 300,
html: 'Super',
cls:'container',
renderTo:Ext.getBody(),
draggable:true,
closable:false,
resizable:{
pinned:true,
dynamic:true
}
}).center();
the container is "resizable", but will only resize on the right and bottom (south, east) side. If I resize the container on the left or top side, the container will not move, it stands on the same position. How to deal with that? If I take a window it change the position too.
For example:
var win = Ext.create('Ext.window.Window', {
plain:true,
width : 300,
height: 300,
html: 'Super',
cls:'container',
renderTo:Ext.getBody(),
draggable:true,
closable:false,
resizable:{
pinned:true,
dynamic:true
}
}).center().show();
Does the job. But I will use a container.
I forget to put "floating:true", windows are per default true, but not containers.
Here is a link introducing this feature: http://www.sencha.com/learn/components/ "Floating Components". Then the containers resizes as aspected.
When i add new buttons to panel i wants to increase the size of that panel dynamically?
Ext.onReady(function() {
Ext.tip.QuickTipManager.init();
Ext.define('myPanel', {
extend:'Ext.panel.Panel',
bodyStyle : {"background-color":"#DFE8F6","padding":"2px"},
width:100,
border:false,
viewConfig:
{
forceFit: true,
}
});
new myPanel({
id:'_panel',
renderTo:Ext.getBody()
});
new Ext.button.Button({
text:'Click Me',
renderTo:Ext.getBody(),
handler:function()
{
Ext.getCmp('_panel').add(new Ext.button.Button({text:'hello'}));
Ext.getCmp('_panel').doLayout();
}
});
});
Here the width is 100.
When i add new buttons to panel the width of the panel should be increased as per new buttons.
Here buttons' sizes will be different for different texts of the button.
Because ExtJS' Components have the functions for their width, so I think you can try:
handler:function()
{
var btn = new Ext.button.Button({text:'hello'});
var panel = Ext.getCmp('_panel');
panel.setWidth(panel.getWidth() + btn.getWidth());
panel.add(btn);
panel.doLayout();
}
Did you set maxWidth or minWidth property? For example if you set maxWidth to 100 and try to setWidth(120) dynamically it won't work.
This is what happened to me. My Sencha Architect UI designer set max width of a panel and I was trying to setWidth() more than the max value.
Wasted an hour for such a silly thing! :(