Two Grids on Same Page Extjs 4 - extjs

I am using this
Ext.define('Wifi.view.widget', {
extend: 'Ext.grid.Panel',
xtype: 'customerlist',
selModel: {
selType: 'cellmodel'
},
height: 380,
width: 700,
viewConfig: {
stripeRows: true
},
initComponent: function() {
Ext.apply(this, {
// Each grid will create its own store now when it is initialized.
store: Ext.create('Wifi.store.Customers'),
plugins: Ext.create('Ext.grid.plugin.CellEditing'),
columns: [{
text: 'Column Name', // Two line header! Test header height synchronization!
locked : false,
width : 200,
sortable : false,
dataIndex: 'columnName'
},{
text : 'Display Name',
width : 200,
sortable : true,
dataIndex: 'displayName',
editor: {
xtype: 'textfield'
}
},{
text : 'Column Width',
width : 150,
sortable : true,
dataIndex: 'columnWidth',
editor: {
xtype: 'numberfield'
}
},{
text : 'Column Type',
width : 100,
sortable : true,
dataIndex: 'columnType',
editor: {
xtype: 'ColumnTypeCombo'
}
}]
});
this.callParent(arguments);
}
});
grid on the same page..
Ext.define('Wifi.view.ViewPortletConfig', {
extend: 'Ext.container.Viewport',
requires: ['Wifi.view.ViewDetailCombo'],
initComponent: function() {
var me = this;
Ext.apply(me, {
items: [
{
region: 'center',
layout:'column',
items : [
{
columnWidth: 1/2,
title: 'Table 1 Column Details',
border:true,
margin:'5 5 5 5',
items:[
{
xtype : 'toolbar',
height:35,
width:700,
border:true,
frame:true,
items: [
'->',
'Select Table: ',
{
margin:'0 50 0 0',
xtype : 'ViewDetailCombo'
}
]
},
{
xtype : 'customerlist'
}
]
},{
columnWidth: 1/2,
title: 'Table 2 Column Details',
border:true,
margin:'5 5 5 5',
items:[
{
xtype : 'toolbar',
height:35,
width:700,
border:true,
frame:true,
items: [
'->',
'Select Table: ',
{
margin:'0 50 0 0',
xtype : 'ViewDetailCombo'
},
]
},
{xtype : 'customerlist'}
]
}
]
}
]
});
me.callParent(arguments);
}
});
Only first grid store is loaded on the change of combo boxes of table 1 and table 2. Can somebody guide me, where is the problem. Thanks in advance.

You have your widget alias wrong. It should look like this:
alias: 'widget.customerlist'
Not xtype! You use xtype: 'customerlist' like you are in both Table N Columns which is a reference to the widget alias 'widget.customerlist'. The definition for the widget needs to change.

Related

How to add search filter in EXTJS

I created a table using extjs where it is having three columns name, email and cars. In extjs we are having a default sorting method. here i want to add search method for all these three columns so that i can also search using the name, email and cars.
What change i need to do for the below code
The expected output is i need to get search filter option under each columns.
Ext.define('ViewerModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.viewermodel',
stores: {
mystore: {
fields: ['name', 'email', 'cars'],
data: {
'items': [{
'name': 'Lisa',
"email": "lisa#simpsons.com"
}, {
'name': 'Bart',
"email": "bart#simpsons.com"
}, {
'name': 'Homer',
"email": "homer#simpsons.com"
}, {
'name': 'Marge',
"email": "marge#simpsons.com"
}]
},
proxy: {
type: 'memory',
reader: {
type: 'json',
rootProperty: 'items'
}
}
}
}
});
Ext.define('APP.HorizontalBox', {
extend: 'Ext.container.Container',
requires: ['Ext.layout.container.HBox'],
xtype: 'layout-horizontal-box',
width: 750,
height: 300,
layout: {
type: 'hbox',
align: 'stretch'
},
bodyPadding: 10,
defaults: {
frame: true,
bodyPadding: 10
},
viewModel: {
type: 'viewermodel'
},
items: [{
xtype: 'grid',
title: 'Grid: click on the grid rows',
itemId: 'myGridItemId',
flex: 1.2,
margin: '0 10 0 0',
bind: {
store: '{mystore}',
selection: '{users}'
},
columns: [{
text: 'Name',
dataIndex: 'name',
flex: 0.5
}, {
text: 'Email',
dataIndex: 'email',
flex: 1
}, {
text: 'Cars',
dataIndex: 'cars',
flex: 1
}],
dockedItems: [{
xtype: 'toolbar',
dock: 'top',
items: [{
xtype: 'button',
padding: '2 5 2 5',
text: 'Edit item',
handler: function (btn) {
var grid = btn.up('grid');
var selectedRow = grid.getSelectionModel().getSelection()[0];
var janela = Ext.create('APP.MyWindow', {
animateTarget: btn.getEl(),
//EDITED
viewModel: {
data: {
users: selectedRow
}
}
}).show();
}
}]
}],
}, {
xtype: 'form',
title: 'View',
itemId: 'panelbindItemId',
flex: 1,
margin: '0 10 0 0',
defaults: {
labelWidth: 50
},
items: [{
xtype: 'displayfield',
margin: '20 0 0 0',
fieldLabel: 'Name',
bind: '{users.name}'
}, {
xtype: 'displayfield',
fieldLabel: 'Email',
bind: '{users.email}'
}]
}]
});
Ext.define('APP.MyWindow', {
extend: 'Ext.window.Window',
alias: 'widget.mywindow',
reference: 'windowreference',
title: 'MyWindow | Edit record',
closable: true,
modal: true,
padding: '10px',
height: 150,
layout: 'fit',
initComponent: function () {
var me = this;
Ext.apply(me, {
items: [{
xtype: 'form',
layout: 'anchor',
defaults: {
padding: '5 0 5 0'
},
items: [{
xtype: 'textfield',
margin: '10 0 0 0',
fieldLabel: 'Name',
bind: '{users.name}'
}, {
xtype: 'textfield',
fieldLabel: 'Email',
bind: '{users.email}'
}]
}]
});
me.callParent(arguments);
}
});
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.create('APP.HorizontalBox', {
renderTo: document.body,
width: 750,
height: 400,
title: 'Title'
});
}
});
You can do it in the afterrender event of grid (Refer this post.) For example:
listeners: {
afterrender: function () {
var menu = Ext.ComponentQuery.query('grid')[0].headerCt.getMenu();
menu.add([{
text: 'Search',
iconCls: 'x-fa fa-home',
handler: function () {
console.log("Search Item");
}
}]);
}
}
Check this Fiddle.
What you are searching for is the FiltersFeature, and the usage is as follows:
xtype:'grid',
...
features:[{
ftype: 'filters',
local: true,
filters: [{
type: 'string',
dataIndex: 'name'
}, {
... (one definition for every column you want to allow filtering one)
}]
}]
Please note that you have to add a requires and maybe even load Ext.ux, as can be found in the last comment.
Other readers please be aware that FiltersFeature is ExtJS4 specific, and has been moved around for ExtJS 5 and 6.
You can also use this code where it will search the data using the date.
listeners: {
afterrender: function () {
var menu = Ext.ComponentQuery.query('grid')[0].headerCt.getMenu();
menu.add([{
xtype:'datefield',
name:'date1',
fieldLabel:'Filter By',
format: 'y-m-d',
listeners:{
renderer: Ext.util.Format.dateRenderer('y-m-d'),
field:{ xtype:'datefield',
autoSync:true,
allowBlank:false,
editor: new Ext.form.DateField(
{format: 'y-m-d'}) }
}
}

How can I Increase space between fields in EXTJS

I have a window where I have items as in below image.I want give gap between fileds
code:
new Ext.Window({
title : bundle.getMsg('add.camera'),
id:'win-add-camera',
closable:true,
autoHeight:true,
modal:true,
defaults : {
labelWidth: 60,
labelAlign: 'left',
margin: '0 0 20 0'
},
items: [{
xtype:'form',
layoutConfig: {
trackLabels: true
},
id: 'form-camera',
autoHeight:true,
autoScroll:true,
items:[
{
layout:'column',
items:[
{
columnWidth: .50,
bodyPadding:30,
margin: '0 0 20 0',
layout: 'form',
defaults:{anchor:'80%'},
items: [ {
id:'cam-name-id',
fieldLabel : bundle.getMsg('camera.name'),
name : 'cameraName',
margin: '0 0 20 0',
xtype:'textfield',
width:450,
emptyText : bundle.getMsg('enter.camName'),
maxLength:10,
enforceMaxLength:true
,required:true,
},
{
id:'url-id',
fieldLabel : bundle.getMsg('url'),
name : 'cameraWebUrl',
xtype:'textfield',
width:450,
margin: '0 0 20 0',
emptyText : bundle.getMsg('enter.url')
,
maxLength:10,enforceMaxLength:true,required:true,
},
{
id:'place-id',
fieldLabel : bundle.getMsg('place.name'),
maxLength:35,
name : 'cameraPlaceName',
xtype:'textfield',
width:450,
emptyText : bundle.getMsg('enter.place'),required:true
},
{
id:'latitude-id',
fieldLabel :bundle.getMsg('lattitude'),
name : 'cameraLatitude',xtype:'textfield',
width:450,emptyText :bundle.getMsg('enter.lattitude'), growMax: 500,required:true
},
{
id:'longitude-id',
fieldLabel : bundle.getMsg('longitude'),
name : 'cameraLongitude',xtype:'textfield',
width:450,emptyText : bundle.getMsg('enter.long'),required:true
},
{
xtype:'combo',
id: 'camera-combo-id',
name:'cameraStatus',
store : new Ext.data.ArrayStore({
data:[["Enable","1"],["Disable","2"]],
fields : ['cameraStatus','no']
}),
fieldLabel : bundle.getMsg('camera.status'),
displayField :'cameraStatus',
emptyText : bundle.getMsg('advice.select'),
valueField : 'no',
selectOnFocus:true,
allowBlank: false,
autoSelect:false,
mode:'local',
listeners:{
'select': function(){
camera_status_combo_value=Ext.getCmp('camera-combo-id').getValue();
camera_status_combo_value_name = Ext.getCmp('camera-combo-id').getRawValue();
alert(camera_status_combo_value)
alert(camera_status_combo_value_name)
},
'afterrender':function(){
this.getStore().load();
}
}
},
{
xtype : 'combo',
id: 'police-station-name-id',
name:'policeStationName',
width:450,
store : police_station_store,
fieldLabel : bundle.getMsg('policestation'),required:true,
displayField :'policeStationName',
emptyText : bundle.getMsg('selectpolicestation'),
valueField : 'gid',
triggerAction:"all",
selectOnFocus:true,
forceSelection: true,
queryMode : 'local',
listeners:{
'select': function(){
police_stn_id=Ext.getCmp('police-station-name-id').getValue();
police_station_combo=Ext.getCmp('police-station-name-id').getValue();
},
'afterrender':function(){
this.getStore().load();
}
}
},
I got the solution
I have written below line in between fields
{
xtype: 'tbspacer',
height:10
},
and also we can add instead of above code
{
height:10
}
both will work !
Before Adding this code:
after adding the code:
You need to set margin for the fields.
Check this fiddle - https://fiddle.sencha.com/#fiddle/md1
The fiddle is in 5.1 but the config is available in 4.x as well.
Use layout:'hbox' for every row.
But, looks like you should use type: 'label' instead of setting label right in the textfield component.
Here is a fiddle for you: https://fiddle.sencha.com/#fiddle/md3
My layout:
layout: {
type: 'vbox',
align: 'stretch'
},
width: 400,
defaults: {
layout: 'hbox',
margin: 10
},
items: [{
items: [{
xtype: 'label',
text: 'Market',
forId: 'test-1',
flex: 1
}, {
xtype: 'combo',
inputId: 'test-1',
allowBlank: false,
store: store,
queryMode: 'local',
displayField: 'MarketName',
forceSelection: true,
valueField: 'Id',
flex: 3
}]
}, {
items: [{
xtype: 'label',
text: 'Name',
forId: 'test-2',
flex: 1
}, {
xtype: 'textfield',
inputId: 'test-2',
flex: 3
}]
}],

Ayuda con extjs 4.2.2 soy nuevo en esto

I'm trying to make the bar that says my panel to collapse but I failed ... I am new to this framework I would like to give me a solution ..
Ext.define('MyApp.view.MyWindow', {
extend: 'Ext.window.Window',
requires: [
'Ext.toolbar.Toolbar',
'Ext.button.Button',
'Ext.grid.Panel',
'Ext.grid.View',
'Ext.grid.column.CheckColumn'
],
autoShow: true,
height: 401,
width: 970,
title: 'Linia de tiempo',
initComponent: function() {
var me = this;
Ext.applyIf(me, {
dockedItems: [
/* {
xtype: 'toolbar',
dock: 'top',
items: [
{
xtype: 'button',
text: 'MyButton'
}
]
} */
],
items: [
{
xtype: 'gridpanel',
title: ' ',
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'string',
width: 250,
text: 'Grado y Sección'
},
{
xtype: 'checkcolumn',
text: 'Inicio'
},
{
xtype: 'checkcolumn',
text: 'Indice'
},
{
xtype: 'checkcolumn',
text: 'Proyecto1'
},
{
xtype: 'checkcolumn',
text: 'Proyecto2'
},
{
xtype: 'checkcolumn',
text: 'Proyecto3'
},
{
xtype: 'checkcolumn',
text: 'Proyecto4'
},
{
xtype: 'checkcolumn',
text: 'Cierre'
}
]
},
{
title : 'Collapsed Panel ' ,
collapsed: true,
collapsible : true,
anchura : 640 ,
//html : KitchenSink . DummyText . MEDIUMTEXT ,
colspan : 3
},
{
xtype: 'panel',
collapseMode: 'standard',
collapsed: true,
collapsible: true,
autoScroll: true,
split:true,
title: 'My Panel'
html: '<iframe src="http://www.google.com" style="width:100%;height:100%;border:none;"></iframe>'
},
/*{
title : 'Collapsed Panel ' ,
se derrumbó : true ,
plegable : true ,
ancho : 640 ,
colspan : 3
} */
]
});
me.callParent(arguments);
}
});
Here is an example for your problem,
Working fiddle is here
Ext.define('MyApp.view.MyWindow', {
//extend: 'Ext.panel.Panel',
extend: 'Ext.window.Window',
alias: 'widget.parentPanel',
requires: ['Ext.toolbar.Toolbar', 'Ext.button.Button', 'Ext.grid.Panel', 'Ext.grid.View', 'Ext.grid.column.CheckColumn'],
autoShow: true,
height: 401,
width: 520,
style:'margin-top: 200px',
title: 'Linia de tiempo',
initComponent: function() {
var me = this;
Ext.applyIf(me, {
dockedItems: [],
items: [{
xtype: 'gridpanel',
title: ' ',
columns: [{
xtype: 'gridcolumn',
dataIndex: 'string',
width: 250,
text: 'Grado y Sección'
}, {
xtype: 'checkcolumn',
text: 'Inicio'
}, {
xtype: 'checkcolumn',
text: 'Indice'
}, {
xtype: 'checkcolumn',
text: 'Proyecto1'
}, {
xtype: 'checkcolumn',
text: 'Proyecto2'
}, {
xtype: 'checkcolumn',
text: 'Proyecto3'
}, {
xtype: 'checkcolumn',
text: 'Proyecto4'
}, {
xtype: 'checkcolumn',
text: 'Cierre'
}]
}, {
xtype: 'panel',
title: 'Collapsed Panel ',
collapsed: false,
collapsible: true,
anchura: 640,
colspan: 3,
items:[{
xtype: 'textfield'
},{
xtype: 'checkbox',
boxLabel: 'select',
boxLabelAlign: 'before'
}]
}, {
xtype: 'panel',
collapseMode: 'standard',
collapsed: true,
collapsible: true,
autoScroll: true,
split: true,
title: 'My Panel',
html: '<iframe src="http://www.google.com" style="width:100%;height:100%;border:none;"></iframe>'
}]
});
me.callParent(arguments);
}
});
Ext.widget('parentPanel', {renderTo: 'panel'});

Rally SDK 2.00 p2 Adding several Checkboxes

I am trying to add Checkboxes for a Rally Report version 2.00p2.
I defined severals place holders for the filter (releaseFilter and stateFilter)
and Adding the checkboxes at the body of the onReady function at the end.
However, Instead of 5 different checkbox I get 1 and on top of the Release filter.
Sorry But I couldn't add an Image.
Rally.onReady(function() {
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
autoScroll: 'true',
items: [
{
xtype: 'container',
itemId: 'releaseFilter',
style: {
margin: '5px'
}
},
{
xtype: 'container',
itemId: 'stateFilter',
style: {
margin: '5px'
}
},
{
xtype: 'container',
itemId: 'grid',
style: {
margin: '10px',
}
},
// SOME CODE
],
launch: function() {
Rally.data.ModelFactory.getModel({
type: 'UserStory',
success: function(model) {
this.grid = this.add({
xtype: 'rallygrid',
model: model,
columnCfgs: [
'FormattedID',
'Release',
'Iteration',
'PlanEstimate',
'PlanDevEstDays',
'PlanQAEstDays'
],
storeConfig: {
filters: [
{
property: 'ScheduleState',
operator: '=',
value: 'Accepted'
}
]
}
});
this.down('#releaseFilter').add(
{
xtype: 'rallyreleasecombobox'
}
);
this.down('#stateFilter').add([{
xtype: 'menucheckitem',
text: 'Backlog',
floating: 'false'
},{
xtype: 'menucheckitem',
text: 'Defined'
},{
xtype: 'menucheckitem',
text: 'In-Progress'
},{
xtype: 'menucheckitem',
text: 'Completed'
},{
xtype: 'menucheckitem',
text: 'Accepted'
}]
);
},
scope: this
});
}
});
Rally.launchApp('CustomApp', {
name: 'Grid Example'
});
});
The original Entry in your javadoc is:
Ext.create('Ext.menu.Menu', {
width: 100,
height: 110,
floating: false, // usually you want this set to True (default)
renderTo: Ext.getBody(), // usually rendered by it's containing component
items: [{
xtype: 'menucheckitem',
text: 'select all'
},{
xtype: 'menucheckitem',
text: 'select specific',
},{
iconCls: 'add16',
text: 'icon item'
},{
text: 'regular item'
}]
});
What did I do wrong ?
Instead of using menucheckitem, use a standard Ext checkbox. Like this:
this.down('#stateFilter').add([{
xtype: 'checkbox',
fieldLabel: 'Backlog'
},
...
]);
Be sure change it from text to fieldLabel

Adding a Grid Panel to the 1st tab of the Tab Panel

I have a GRID which works properly. Now I need to add this GRID to the first Tab Panel. How can I do that?
my code:
GRID.JS
Ext.create('Ext.grid.Panel', {
xtype:'grid',
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ header: 'Name', dataIndex: 'name' },
{ header: 'Email', dataIndex: 'email', flex: 1 },
{ header: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});
TAB.JS
Ext.create('Ext.tab.Panel', {
width: 300,
height: 200,
activeTab: 0,
items: [
{
title: 'Tab 1',
xtype:'grid'
},
{
title: 'Tab 2',
html : 'Another one'
}
],
renderTo : Ext.getBody()
});
I have added the xtype:grid in GRID.JS and I am trying to access that Grid from TAB.JS in the 1st tab, but it is not getting displayed.
xtype: 'grid' - means create standard Ext.grid.Panel and add it here.
You have two options:
Create your grid and save it into variable.
var _grid = Ext.create('...', {...});
Ext.create('Ext.tab.Panel', {
...
items: [
_grid
]
});
Or, define your own class with new xtype
Ext.define('MyGrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.mygrid',
...
});
Ext.create('Ext.tab.Panel', {
...
items: [{
xtype: 'mygrid'
}]
});

Resources