I have an ExtJS form constructed within a grid's tbar which allows for filtering of grid results.
The structure is, visually:
A combobox for specifying date type
A combobox for specifying date range type
then potentially either:
Nothing
or
A combobox containing specific date values
or
Two datepickers
ended with a textfield for further filtering on text values within the results.
All form fields are arranged horizontally ("column" layout).
One of the date range types is "All", which removes the need for the combobox with specific date values or datepickers, both options taking up the same space. In the interest of visual consistency the text filter is to stay in the same place regardless of what is between it and the date range type combobox.
I would assume that there would be some property that can be applied to place the textfield dependent on the date range combobox, and I've seen AlignTo which looks promising, but not directly related to a textField.
Can AlignTo or similar be used to set a form field a set distance from another form field, and if so how?
Example code:
xtype: 'form',
id: 'gridFilterForm',
url: '<?= $site_url ?>Production/Schedule',
layout: 'column',
standardSubmit: true,
// The fields
defaultType: 'textfield',
items: [
{
xtype: 'combobox',
id: 'dateFilterPicker',
store: dateFilterPickStore,
querymode: 'local',
editable: false,
fieldLabel: 'Filter Type:',
labelWidth: 45,
labelAlign:'top',
displayField:'name',
valueField:'value',
value: '<?= $this->data['filterDateType'] ?>',
listeners: {
change: loadProductionItems
}
},
{
xtype: 'combobox',
id:'dateRangePick',
store: dateRangePickStore,
queryMode: 'local',
editable: false,
fieldLabel: 'Filter On:',
labelAlign:'top',
labelWidth: 45,
displayField: 'name',
valueField: 'value',
value: '<?= $this->data['filterDateRange'] ?>',
listeners:{
change: changeStoresAndFilters
},
width: 65,
allowBlank: false
},{
xtype: 'combobox',
id:'dateRangeFrom',
fieldLabel: 'Range:',
labelAlign:'top',
editable: false,
labelWidth: 45,
store: dateRangeStore,
queryMode: 'remote',
displayField: 'Name',
valueField: 'Id',
columnWidth:.60,
listeners: {
select: function(value){
// actions
}
}
},{
xtype:'datefield',
id: 'fromDatePicker',
fieldLabel: 'From',
labelAlign:'top',
editable: false,
labelWidth: 40,
hidden: true,
disabled: true,
columnWidth:.30,
format: 'd M Y',
listeners: {
select: function(){
// actions
}
}
},{
xtype:'datefield',
id: 'toDatePicker',
fieldLabel: 'To',
labelAlign:'top',
editable: false,
labelWidth: 30,
hidden: true,
disabled: true,
columnWidth:.30,
format: 'd M Y',
listeners: {
select: function(){
// actions
}
}
},{
xtype: 'textfield',
id: 'searchTextBox',
fieldLabel: 'Search Text:',
labelAlign:'top',
labelWidth: 70,
columnWidth:.30,
listeners: {
change: function(){
// actions
}
}
}
]
Managed some form of a workaround:
Firstly, works only with explicit width columns: [code]columnWidth[/code] changes to [code]width[/code] and width values become numbers of pixels.
Have a displayfield, just before the text field, that can occupy the same width as the combobox/datepickers it "replaces", and have it be hidden until it is needed (i.e. both the combobox or datepickers are hidden), with various hide() and show() calls.
Remarkably simple, but I'd have thought there was better layout control in ExtJS and wouldn't have needed additional elements.
code:
... //combobox and datepickers
{
id: 'spacer',
xtype: 'displayfield',
width: 240
},
... // textfield search box
Related
My problem is, even if I used "layout: 'fit'" in all my children items within a boarder layout, they just shrinks into a small box rather than fill the parent, as described in fit layout.
I want the EDS.view.selector.Container to fill the "navigation" section of my boarder layout.
(Code excerpt)
Ext.define('EDS.view.selector.Container', {
extend: 'Ext.panel.Panel',
alias : 'widget.selectorcontainer',
layout: 'fit',
initComponent: function(){
this.items = [
{
xtype: 'tabpanel',
defaults: {
bodyPadding: 10
},
layout: 'fit',
items:[
{
title: 'Organization',
id: 'selector-organization',
tag: 'div',
html: 'div here',
height: '100%',
}
]
}
],
this.callParent();
},
});
(Controller)
init: function(){
console.log('controller.init()');
new Ext.Viewport({
title: 'Data Analysis',
layout: 'border',
defaults: {
collapsible: true,
split: true,
bodyStyle: 'padding: 15px',
},
items: [{
title: 'Navigation',
region:'west',
margins: '5 0 0 0',
cmargins: '5 5 0 0',
width: 600,
minSize: 100,
maxSize: 250,
items: [
{
id: 'selector-container',
xtype: 'selectorcontainer',
layout: 'fit',
}
]
},{
title: 'Main Content',
collapsible: false,
region:'center',
margins: '5 0 0 0'
}]
});
}
You did not set up layout for wrapper containers in your border layout:
items: [{
title: 'Navigation',
region:'west',
layout: 'fit',
...
items: [
]
},{
title: 'Main Content',
collapsible: false,
region:'center',
layout: 'fit',
...
}]
Remember: In ExtJS any plain JS object that goes into items property of a container will be converted into some type of Ext component with xtype defined by defaultType property of that container. In most cases it will be panel.
I'm trying to create a container that has four items, and what I need is the container to be the one that scroll instead of each individual item, also I want every item to have it's own height so if the four items are bigger than the screen the user can scroll down through the container to see the other items info...
JSFiddle:
http://jsfiddle.net/martuanez/7GV3b/
My code:
var store = {
type: 'store',
fields: ['label', 'value'],
data: [{
label: 'label',
value: 'value',
}, {
label: 'label',
value: 'value',
}, {
label: 'label',
value: 'value',
},
]
};
Ext.Loader.setConfig({
enabled: true
});
Ext.application({
name: ('SF' || 'SenchaFiddle'),
launch: function () {
Ext.define('MyApp.view.Contacts.ContactsDetailsView', {
xtype: 'ContactsDetailsView',
extend: 'Ext.Container',
config: {
layout: {
type: 'vbox',
padding: 3
},
defaults: {
scrollable: {
direction: 'horizontal',
directionLock: true
},
height: 500,
layout: 'fit'
},
scrollable: 'vertical',
itemCls: 'details-list-container',
items: [{
xtype: 'dataview', //add xtype
itemId: 'detailItem',
loadingText: 'Loading keys...',
emptyText: '<div>No keys found.</div>',
store: store,
onItemDisclosure: false,
itemTpl: '<br/>item 1:<br/> {label}<br/>{value}<br/><br/>',
itemCls: 'details-list',
selectedItemCls: '',
disableSelection: true,
pressedCls: ''
}, {
xtype: 'list',
itemId: 'detailKeys',
store: store,
loadingText: 'Loading keys...',
emptyText: '<div>No keys found.</div>',
onItemDisclosure: false,
itemTpl: 'item 2: {label}{value}<br/>',
itemCls: 'details-list',
selectedItemCls: '',
disableSelection: true,
pressedCls: ''
}, {
xtype: 'list', //add xtype
itemId: 'detailuserdefs',
store: store,
loadingText: 'Loading userdefs...',
onItemDisclosure: false,
itemTpl: 'item 3: {label}{value}<br/>',
itemCls: 'details-list',
selectedItemCls: '',
disableSelection: true,
pressedCls: ''
}, {
xtype: 'list',
itemId: 'detailOthers',
store: store,
loadingText: 'Loading userdefs...',
onItemDisclosure: true,
itemTpl: 'item 4: {label}{value}<br/>',
itemCls: 'details-list'
}
]
}
});
Ext.Viewport.add(Ext.create('MyApp.view.Contacts.ContactsDetailsView'));
}
});
I´ve finally make it work, i set scrollable to false in the defaults section of the container and a height on the child items.
One thing that happened is that when setting scrollable to false in the childs, not in the defaults, sencha didn't recognize the height, this is a bug that they claim they have fixed already, actual version by the time i'm writting this 2.2, version i'm working on 2.1.1
Note: I also managed to set dinamic heights on each item, i did this by setting it apart and adding the items later by doing myContainer.add(itemWithDinamicHeight);
;)
Cheers!
I have a set of data in my dataStore, and I output my data using textfields within containers in a .js view. I also disabled the fields only to show data and be uneditable. I was wondering if there are any alternatives to using 'xtype: textfield', and 'xtype: textareafield' ?
With this question entailed, I'm trying to create a container with two components using hbox as such an alternative, and this is the code that I have of the following:
var formContainer1 = new Ext.Container({
width: '100%',
height: '65%',
layout: {
type: 'vbox',
// type: 'hbox',
align: 'stretch',
},
defaults: {
labelAlign:'left',
// labelWidth:'30%',
labelWidth:'25%',
},
items: [
{
bodyStyle: "background-color: #52ABD5;", //Color = Light Blue
html: '<font face="Helvetica" size="4" color="white" ><p>Information</p>'
},
{
xtype: 'textfield',
// xtype: 'component',
name: 'Description',
disabled: true,
label: 'Desc',
},{
xtype: 'textfield',
// xtype: 'component',
name: 'Number',
disabled: true,
label: 'ANumber',
id: 'ANumber',
},{
xtype: 'textareafield',
// xtype: 'component',
name: 'directions',
disabled: true,
label: 'Directions',
height: 'auto',
// defaults: {
//required: true,
// labelAlign: 'left',
// labelWidth: '100%'
// },
},
],
/* dockedItems: [
{
layout: 'hbox',
xtype: 'toolbar',
dock: 'top',
title: 'Information',
// scroll: 'horizontal',
}
]*/
});
Now this code works just fine, except i don't want to use 'textfield' or 'textareafield'. I'm still using those because I tried using xtype: component, but it didn't work. Also when I tried this in hbox layout, it didn't show up like I wanted it to (row after row). I'm pretty sure I'm just not understanding the "components using hbox" part because yeah I want this container to look really close to this:
Img url: http://farm3.staticflickr.com/2683/5852914556_b2886e3363.jpg
(note: referring to the right most iphone picture w/ the containers)
Please clarify for me on the "w/ 2 components usnig hbox" part. Thanks!
By the way: http://www.sencha.com/forum/showthread.php?186243-Alternatives-to-textfield&p=759843#post759843
My username on that post: kevinjset. This was the original post that I posted on Sencha touch forums asking the same question, I just wanted to see if you guys on Stack Overflow! can help me out too! Thanks, appeciated.
This is fairly tedious but it might help you out
{
xtype:'fieldset',
title:'fieldset1',
items:[{
xtype:'container',
layout:'hbox',
items:[{
xtype:'container',
flex:1,
html:'1'
},{
xtype:'container',
flex:1,
html:'2'
},{
xtype:'container',
flex:1,
html:'3'
}]
},{
xtype:'container',
layout:'hbox',
items:[{
xtype:'container',
flex:1,
html:'4'
},{
xtype:'container',
flex:1,
html:'4'
},{
xtype:'container',
flex:1,
html:'6'
}]
}]
}
i have a treegrid and i need to make it as editorGrid.
My treegrid is
var tree = new Ext.ux.tree.TreeGrid({
title: 'Core Team Projects',
height: 500,
renderTo: Ext.getBody(),
autoLoad:false,
plugins: [editor],
columns:[
{
header: 'Name',
dataIndex: 'name',
width: 230
},{
header: 'length',
width: 150,
sortType: 'asFloat',
dataIndex: 'length'
},{
header: 'size',
width: 150,
sortType: 'asFloat',
dataIndex: 'size'
},{
header: 'dataType',
width: 150,
dataIndex: 'dataType'
},{
header: 'extName',
width: 150,
dataIndex: 'extName'
},{
header: 'overlay',
width: 150,
dataIndex: 'overlay'
},{
header: 'qualified',
width: 150,
dataIndex: 'qualified'
}],
loader: myTreeLoader
});
and the editor which i used is
var editor = new Ext.ux.grid.RowEditor({
saveText: 'Save',
errorSummary : true,
monitorValid: true,
clicksToEdit: 1,
// floating: true,
shadow: true,
layout: 'hbox',
cls: 'x-small-editor',
buttonAlign: 'center',
baseCls: 'x-row-editor',
elements: 'header,footer,body',
frameWidth: 5,
buttonPad: 3,
focusDelay: 250,
cancelText: 'Cancel',
//commitChangesText: 'You need to Update or Cancel your changes',
// errorText: 'Errors',
defaults: {
normalWidth: true
}
});
it gives an error "Object doesn't support this property or method"
Could Someone pls give a solution
The "Ext.ux.tree.TreeGrid" in Extjs v3.x.x is not a real "grid" (based on treepanel + treeloader...), that's why you can't use "Ext.ux.grid.RowEditor" (because roweditor need a grid + store...).
2 Solutions:
Switch to Extjs v4.x.x and you can use "Ext.grid.plugin.CellEditing":
ExtJs TreeGrid with editor column. Exists?
Override createNode (in "Ext.ux.tree.TreeGridLoader") or modify the "Ext.ux.tree.TreeGridNodeUI":
http://www.sencha.com/forum/showthread.php?118393-treegrid-checkbox-extension
Checkbox Column in ExtJS TreeGrid
(Examples to put checkboxes you can modify to put others components...)
Good luck...
I want to use viewport and use accordion layout for my menu items.
but I want my accordion layout not fill and use all spaces for each item
I use layoutConfig like examples but it dosn't work and the accordion fill all spaces and stretch vertically :
this.view = new Ext.Viewport({
layout: 'border',
renderTo : document.body,
items: [{
xtype: 'box',
region: 'north',
height: 60,
contentEl: 'framework_north'
},{
region: 'east',
title: 'امکانات سیستم',
split: true,
collapsible: true,
width: 200,
minSize: 200,
maxSize: 200,
layout:'accordion',
layoutConfig: {
fill : false,
collapseFirst : true,
hideCollapseTool : true
},
tbar : [
{
contentEl : "framework_clock",
autoWidth : true,
xtype: 'box',
height : 80
}],
items: this.menuItems
},
this.centerPanel]
});
what is my fault :'(
wrap your accordion in a vbox container and set the height to whatever you want.