Grid inside Tab - extjs

I'm trying to put a Grid (Ext.grid.GridPanel) object inside a Tab .
This is the code:
var grid = new Ext.grid.GridPanel({
store: new Ext.data.Store({
autoDestroy: true,
reader: reader,
data: xg.dummyData
}),
colModel: new Ext.grid.ColumnModel({
defaults: {
width: 120,
sortable: true
},
columns: [
{id: 'company', header: 'Company', width: 200, sortable: true, dataIndex: 'company'},
{header: 'Price', renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
{header: 'Change', dataIndex: 'change'},
{header: '% Change', dataIndex: 'pctChange'},
// instead of specifying renderer: Ext.util.Format.dateRenderer('m/d/Y') use xtype
{
header: 'Last Updated', width: 135, dataIndex: 'lastChange',
xtype: 'datecolumn', format: 'M d, Y'
}
]
}),
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
width: 600,
height: 300,
frame: true,
title: 'Framed with Row Selection and Horizontal Scrolling',
iconCls: 'icon-grid'
});
this.tabs = new Ext.TabPanel({
fullscreen: true,
type: 'dark',
sortable: true,
dockedItems: [
{
xtype:'toolbar',
title:'Hello World'
}],
tabBar: {
ui: 'light',
layout: {
pack: 'left'
}
},
items: [
{
cls:'hello',
id:'tab1',
html : '<a>hello</a>',
title:'Monitor'
}, {
cls:'world',
id:'tab2',
xtype: 'map',
html : '<a>hello world</a>',
title:'Map'
}, {
cls:'world',
id:'tab3',
html : '<a>hello world</a>',
dockedItems:grid
}]
});
When I load the page there's no error, but the grid is not shown.

The grid is not a docked item (that's for toolbars and other things that should stick to one side of a container). If you want the grid to take up the entire tab, just add it directly as an item to the TabPanel and it will become the full tab:
items: [
{
cls:'hello',
id:'tab1',
html : '<a>hello</a>',
title:'Monitor'
}, {
cls:'world',
id:'tab2',
xtype: 'map',
html : '<a>hello world</a>',
title:'Map'
},
grid ]

Related

ExtJS 4 - Popup on cellclick in grid panel is not displayed

I have a Problem to open a popup window on cellclick.
When i click on the cell everything overlaid grey, but the window is not displayed.
The code is in the follow. Any idea why the new Window is not displayed?
Thanks and Regards.
var win = Ext.widget('window', {
title: 'Contact Us',
closeAction: 'hide',
width: 400,
height: 400,
minHeight: 400,
layout: 'fit',
resizable: true,
modal: true,
//items: form
});
Ext.define('File',{
extend: 'Ext.data.Model',
fields: [
{name: 'file_id'},
{name: 'file_input_filename'},
{name: 'file_type'},
{name: 'lc_status'},
{name: 'file_input_date'}
]
});
// create the Data Store
var overviewStore = Ext.create('Ext.data.Store', {
model: 'File',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'FileOverview',
reader: {
type: 'xml',
// records will have an "Item" tag
record: 'Row',
idProperty: 'file_id',
totalRecords: '#total'
}
}
});
// create the grid
var gridOverview = Ext.create('Ext.grid.Panel', {
store: overviewStore,
id: 'OverviewGridPanelId',
columns: [
{text: "ID", flex: 1, dataIndex: 'file_id', sortable: true},
{text: "Filename", width: 180, dataIndex: 'file_input_filename', sortable: true},
{text: "Filetyp", width: 180, dataIndex: 'file_type', sortable: true},
{text: "Status", width: 180, dataIndex: 'lc_status', sortable: true},
{text: "Imported", width: 115, dataIndex: 'file_input_date', sortable: true}
],
renderTo:'binding-example',
width: 1200,
height: 650,
});
gridOverview.on('cellclick', function(table, td, cellIndex, record, tr, rowIndex, e, eOpts) {
var masterIndex = rowIndex;
//openDialog(record.get('file_id'));
Ext.Msg.alert('locked grid click');
win.show();
});
}

Ext JS - loading values in second grid based on row selection in first grid

I have 2 grids... In the first grid, I am showing some details but the second grid will be empty. When I choose any row in the first grid, the second grid has to show the values based on the row value from the first grid.
for 1st grid,
Ext.define('Admin.view.report004.Dashboard400',
{
alias: 'widget.report004.list400',
itemId: 'dashboard400',
title : 'Summary By Bank',
stripeRows: true,
border: true,
loadMask: {
msg: 'Please wait..'
},
extend: 'Ext.grid.GridPanel',
layout : 'fit',
bodyPadding: 10,
title: bundles.getLocalizedString('summary_by'),
store: report004Store,
features: [{
ftype: 'summary'
}],
columns: [
{id: 'report004CustomerName', header: bundles.getLocalizedString('customer_name'),
width: 150, sortable: false, hidden: false,
dataIndex: 'customerName',
align:'left',
summaryRenderer: function(value, summaryData, dataIndex) {
return '<b>Totals</b>';
}
},
{id: 'report004Count', header: bundles.getLocalizedString('count'),
width: 150, sortable: false, hidden: false,
dataIndex: 'count',
align:'left'
},
]
});
For grid 2,
Ext.define('Admin.view.report004.Dashboard401',
{
alias: 'widget.report004.list100',
itemId: 'dashboard401',
title : 'By Specific Dataset',
stripeRows: true,
border: true,
loadMask: {
msg: 'Please wait..'
},
extend: 'Ext.grid.GridPanel',
layout : 'fit',
bodyPadding: 10,
title: bundles.getLocalizedString('xxx'),
store: dashboard_401,
features: [{
ftype: 'summary'
}],
columns: [
{
id: 'name2', header: bundles.getLocalizedString('name'),
width: 200, sortable: false, hidden: false,
dataIndex: 'name',
summaryRenderer: function(value, summaryData, dataIndex) {
return '<b>Totals</b>';
}
},
{id: 'companyPaidCount2', header: bundles.getLocalizedString('paid_count'),
width: 150, sortable: false, hidden: false,
dataIndex: 'companyPaidCount',xtype: 'numbercolumn', format : '0,000',
align:'right',
summaryType: 'sum',
summaryRenderer: function(value, summaryData, dataIndex){
return "<b>" + value + "</b>";
}
]
});
Kindly help me on this..
Use select listener
for your first grid. grid select listener
Ext.define('Admin.view.report004.Dashboard400', {
alias: 'widget.report004.list400',
itemId: 'dashboard400',
title: 'Summary By Bank',
stripeRows: true,
border: true,
loadMask: {
msg: 'Please wait..'
},
extend: 'Ext.grid.GridPanel',
layout: 'fit',
bodyPadding: 10,
title: bundles.getLocalizedString('summary_by'),
store: report004Store,
features: [{
ftype: 'summary'
}],
listeners: {
select: function(grid, record, index) {
Ext.Ajax.request({
url: 'page.php',
params: {
id: record.get("id")
},
success: function(response) {
var data = Ext.decode(response.responseText);
dashboard_401.loadData(data);
}
});
}
},
columns: [
{
id: 'report004CustomerName',
header: bundles.getLocalizedString('customer_name'),
width: 150,
sortable: false,
hidden: false,
dataIndex: 'customerName',
align: 'left',
summaryRenderer: function(value, summaryData, dataIndex) {
return '<b>Totals</b>';
}
}, {
id: 'report004Count',
header: bundles.getLocalizedString('count'),
width: 150,
sortable: false,
hidden: false,
dataIndex: 'count',
align: 'left'
},
]
});

Extjs gridfilters

I have an issue with gridfilters plugin
« Filters » option is visible but the sub-menu for Filters option is not visible
I have this warning in console
"Using showBy on a non-floating component"
The grid definition is :
xtype: 'grid',
store: store,
iconCls: 'icon-grid',
frame: true,
width: 700,
height: 500,
dockedItems: [{
xtype: 'pagingtoolbar',
store: store, // mismo que el store GridPanel
dock: 'bottom',
displayInfo: true
}],
plugins: ['gridfilters'],
columns: [
{header: 'Company',dataIndex: 'company', flex: 1,
filter:
{
type: 'string',
itemDefaults: {
emptyText: 'Search for...'
}
},
editor: {
xtype: 'textfield'
}
},
{header: 'Price',dataIndex: 'price', flex: 1,
filter: 'number'
},
{header: 'Change',dataIndex: 'change', flex: 1},
{header: 'Last change',dataIndex: 'lastChange',xtype: 'datecolumn', format:'d/m/Y', flex: 1}
]
Can you help me about this point?
Try using the features property instead of the plugins one, as follows:
features: {
ftype: 'filters',
encode: true,
local: false
}

how to show data store grid on ext.window.window.modal

I have a problem rendering data store grid on window modal.
here's the code on data.store :
var list_pp = Ext.create('Ext.data.Store', {
pageSize: itemsPerPage,
model: 'list_pp',
proxy: {
type: 'ajax',
api: {
read: pp_get_url,
create: pp_set_url,
update: pp_up_url,
destroy: pp_del_url
},
reader: {
type: 'json',
root: 'data',
totalProperty: 'totalCount'
},
writer: {
type: 'json',
writeAllFields: true,
root: 'data'
}
},
//autoLoad: false,
listeners: {
write: function(store, operation){
var record = operation.getRecords()[0],
name = Ext.String.capitalize(operation.action),
verb;
}
}
});
here's the code that render on some page :
var grid_pp_list = Ext.create('Ext.grid.Panel',
{
width: '100%',
frame: false,
loadMask: true,
collapsible: false,
title: 'Detail PP',
store: list_pp,
columns: [
{
header: 'No PP',
width: 130,
sortable: true,
dataIndex: 'doc_no',
xtype: 'templatecolumn',
tpl: '{doc_no}<br/>{pp_id}/{sifat}<br/>'
}, {
header: 'Tgl.',
width: 100,
sortable: true,
dataIndex: 'pp_date',
xtype: 'datecolumn',
format:'y-m-d'
}, {
header: 'SBU Pemesan',
width: 160,
sortable: true,
dataIndex: 'org_order',
xtype: 'templatecolumn',
tpl: '{org_order}'
},{
header: 'Validasi',
width: 160,
sortable: true,
dataIndex: 'org_order',
xtype: 'templatecolumn',
tpl: '{org_order}'
},{
header: 'Action',
xtype: 'actioncolumn',
width: 60,
sortable: false,
menuDisabled: true,
xtype: 'templatecolumn',
tpl: 'Detail'
},{
header: 'Modified by',
width: 120,
dataIndex: 'modified_by',
sortable: true,
xtype: 'templatecolumn',
tpl: '<i class="icon-user"></i>{modified_by}'
},{
header: 'Modified Date',
width: 120,
sortable: true,
dataIndex: 'modified_date',
xtype: 'datecolumn',
format:'y-m-d H:m:s'
}]
here's the code on window modal :
var modal_pp = Ext.create('Ext.grid.Panel',
{
width: '100%',
frame: false,
loadMask: true,
collapsible: false,
title: 'Modal PP',
store: list_pp,
columns: [
{
header: 'No PP',
width: 130,
sortable: true,
dataIndex: 'doc_no',
xtype: 'templatecolumn',
tpl: '{doc_no}<br/>{pp_id}/{sifat}<br/>'
}, {
header: 'Tgl.',
width: 100,
sortable: true,
dataIndex: 'pp_date',
xtype: 'datecolumn',
format:'y-m-d'
}, {
header: 'SBU Pemesan',
width: 160,
sortable: true,
dataIndex: 'org_order',
xtype: 'templatecolumn',
tpl: '{org_order}'
}],
dockedItems:
[{
xtype: 'pagingtoolbar',
store: list_pp, // same store GridPanel
dock: 'bottom',
displayInfo: true
}]
});
here's generate trigger button trigger for modal window:
text: 'Generate',
iconCls: 'icon-add',
handler: function(){
if (!win) {
win = Ext.widget('window', {
closeAction: 'hide',
width: 1000,
height: 620,
minWidth: 300,
minHeight: 300,
layout: 'fit',
resizable: true,
modal: true,
items: modal_pp
});
}
win.show();
}
in rendering page everything is fine, but in window modal i can't render data store. please if anyone can give a guide or help i will be really appreciate it.
Remove width attributes from the modal grid. You cant specify width in % and if your containing parent has fit layout it doesn't matter anyway.
Wrap items in an array: items: [modal_pp]

Why My Ext.GridPanel can not get data to render in other Ext.Panel?

Next code can not working, my gridpanel can not render ok:
Ext.onReady(function(){
Ext.namespace('App', 'App.ui', 'App.data');
// Add the additional VTypes
Ext.apply(Ext.form.VTypes, {
password : function(val, field) {
if (field.initialPassField) {
var pwd = Ext.getCmp(field.initialPassField);
return (val == pwd.getValue());
}
return true;
},
passwordText : 'Passwords do not match'
});
App.data.userstore = new Ext.data.DirectStore({
autoLoad: true,
directFn: ExtDirect.UserController.selectAll,
paramsAsHash: true,
idProperty: 'UserID',
listeners: {
load: function(s, records){
//Ext.MessageBox.alert( "Information", "Loaded " +
//records.length + " records");
}
},
fields : [ 'UserID', 'UserLevelID', 'UserName', 'Password',
'FirstName', 'LastName', 'Email', 'Skype',
'OfficePhone', 'CellPhone', 'Position' ]
})
// row expander
var expander = new Ext.ux.grid.RowExpander({
tpl : new Ext.Template(
'<p><b>Company:</b> {company}</p><br>',
'<p><b>Summary:</b> {desc}</p>'
)
});
var sm = new Ext.grid.CheckboxSelectionModel();
//Let's pretend we rendered our grid-columns with meta-data from our ORM framework.
App.userColumns = [
{header: "UserID", width: 100, sortable: true, dataIndex: 'UserID'},
{header: "UserLevelID", width: 100, sortable: true, dataIndex: 'UserLevelID', editor: new Ext.form.ComboBox({})},
{header: "UserName", width: 100, sortable: true, dataIndex: 'UserName', editor: new Ext.form.TextField({})},
{header: "Password", width: 100, sortable: true, dataIndex: 'Password'},
{header: "FirstName", width: 100, sortable: true, dataIndex: 'FirstName', editor: new Ext.form.TextField({})},
{header: "LastName", width: 100, sortable: true, dataIndex: 'LastName', editor: new Ext.form.TextField({})},
{header: "Email", width: 100, sortable: true, dataIndex: 'Email', editor: new Ext.form.TextField({})},
{header: "Skype", width: 100, sortable: true, dataIndex: 'Skype', editor: new Ext.form.TextField({})},
{header: "OfficePhone", width: 100, sortable: true, dataIndex: 'OfficePhone', editor: new Ext.form.TextField({})},
{header: "CellPhone", width: 100, sortable: true, dataIndex: 'CellPhone', editor: new Ext.form.TextField({})},
{header: "Position", width: 100, sortable: true, dataIndex: 'Position', editor: new Ext.form.TextField({})}
];
App.ui.editor = new Ext.ux.grid.RowEditor({
saveText: 'Update'
});
// create the Grid
App.ui.grid = new Ext.grid.GridPanel({
store: App.data.userstore,
columns: App.userColumns,
stripeRows: true,
plugins: [expander],
layout: 'fit',
height: 250,
width: 500,
title: 'DB Grid',
sm: new Ext.grid.RowSelectionModel({
singleSelect: true,
listeners: {
rowselect: function(sm, row, rec) {
Ext.getCmp("userformgrid-panel").getForm().loadRecord(rec);
}
}
}),
columnLines: true,
frame: true,
listeners: {
viewready: function(g) {
g.getSelectionModel().selectRow(0);
} // Allow rows to be rendered.
},
// inline toolbars
tbar:[{
text:'Add Something',
tooltip:'Add a new row',
iconCls:'add'
}, '-', {
text:'Options',
tooltip:'Blah blah blah blaht',
iconCls:'option'
},'-',{
text:'Remove Something',
tooltip:'Remove the selected item',
iconCls:'remove',
// Place a reference in the GridPanel
ref: '../removeButton',
disabled: true
}],
});
App.data.userstore.load();
App.ui.adduser = new Ext.FormPanel({
id: 'adduser-panel',
labelWidth: 75, // label settings here cascade unless overridden
frame: true,
title: 'Add a new user',
bodyStyle:'padding:5px 5px 0',
width: 350,
items: [{
xtype:'fieldset',
checkboxToggle:false,
title: 'Account Information',
autoHeight:true,
defaults: {width: 210},
defaultType: 'textfield',
collapsed: false,
items :[{
fieldLabel: 'User Name',
name: 'username',
allowBlank:false
},{
fieldLabel: 'Password',
name: 'password',
id: 'password',
allowBlank:false
},{
fieldLabel: 'Confirm Password',
name: 'pass-cfrm',
id: 'pass-cfrm',
vtype: 'password',
initialPassField: 'password' // id of the initial password field
}]
}, {
xtype:'fieldset',
checkboxToggle:false,
title: 'Personal Information',
autoHeight:true,
defaults: {width: 210},
defaultType: 'textfield',
collapsed: false,
items :[{
fieldLabel: 'First Name',
name: 'firstname',
allowBlank:false
},{
fieldLabel: 'Last Name',
name: 'lastname',
allowBlank: false
}, {
fieldLabel: 'Email',
name: 'email',
vtype:'email',
allowBlank: false
}
]
},{
xtype:'fieldset',
title: 'Other',
collapsible: true,
autoHeight:true,
collapsed: true,
defaults: {width: 210},
defaultType: 'textfield',
items :[{
fieldLabel:'Skype',
name:'skype'
}, {
fieldLabel:'Office Phone',
name:'phone'
}, {
fieldLabel:'Cell Phone',
name:'cellphone'
}, {
fieldLabel:'Position',
name:'posion'
}, {
xtype: 'fileuploadfield',
emptyText: 'Select an image',
fieldLabel:'Picture',
name:'picture',
id: 'picture',
buttonText: '',
buttonCfg: {
iconCls: 'upload-icon'
}
}, {
xtype: 'textarea',
fieldLabel:'Comment',
name:'comment',
flex: 1 // Take up all *remaining* vertical space
}]
}],
buttons: [{
text: 'Submit'
},{
text: 'Clear'
}]
});
var viewport = new Ext.Viewport({
layout:'border',
items:[{
region:'west',
id:'west-panel',
title:'West',
split:true,
width: 200,
minSize: 175,
maxSize: 400,
collapsible: true,
margins:'35 0 5 5',
cmargins:'35 5 5 5',
layout:'accordion',
layoutConfig:{
animate:true
},
items: [{
html: Ext.example.shortBogusMarkup,
title:'Navigation',
autoScroll:true,
border:false,
iconCls:'nav'
},{
title:'Settings',
html: Ext.example.shortBogusMarkup,
border:false,
autoScroll:true,
iconCls:'settings'
}]
},{
region:'center',
margins:'35 5 5 0',
layout:'fit',
autoScroll:true,
items: [{
columnWidth:.4,
baseCls:'x-plain',
bodyStyle:'padding:5px 0 5px 5px',
items:[App.ui.adduser]
},{
columnWidth:.60,
layout: 'fit',
baseCls:'x-plain',
bodyStyle:'padding:5px',
items:[App.ui.grid]
}]
}]
});});
But next code can working:
{
region:'center',
margins:'35 5 5 0',
layout:'fit',
autoScroll:true,
items: [App.ui.adduser, App.ui.grid]
}
Why? I just wrapped App.ui.grid with a panel, why it can not render the data? Thanks for any help!!!
Layout:'fit' is intended for a single child panel, but you are adding two child panels as columns, so I assume you want layout:'column' instead? Also your column panel that contains App.ui.adduser does not have any layout specified, which could also cause problems.

Resources