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

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]

Related

How to switch between cards in card layout

I have a card layout having two cards one with tab panel.Inside tab panel grid panel is there and another card is my content panel. I have to switch to next card i.e my content panel on cell click on my grid panel.
Have used the setActiveitem() function but something is wrong.
extend: Ext.panel.Panel,
id: 'cardpanel',
width: 300,
height: 1000,
reference: 'resultcardPanel',
itemid: 'cardPanel',
layout: {
type: 'card',
anchor: '100%'
},
activeItem: 0,
xtype: 'searchresults',
bodyStyle: 'padding:15px',
defaults: {
border: false
},
controller: 'email',
viewModel: {
type: 'email'
},
items: [{
xtype: 'tabpanel',
//id:'searchresults',
requires: [
'Ext.grid.Panel',
'Ext.toolbar.Paging',
'Ext.grid.column.Date'
],
cls: 'shadow',
activeTab: 0,
margin: 20,
///////////////////////////////////////////////////////
items: [{
xtype: 'grid',
cls: 'allRecordsCls',
scrollable: false,
border: false,
title: 'Primary',
routeId: 'inbox',
bind: '{inbox}',
itemclick: function() {
centerpanel = new Ext.Panel({
layout: 'card',
items: [homepanel, browser.grid]
});
centerpanel.getLayout().setActiveItem(1);
},
selModel: {
selType: 'checkboxmodel',
checkOnly: true,
showHeaderCheckbox: true
},
headerBorders: false,
rowLines: false,
scrollable: false,
listeners: {
itemclick: 'onGridCellItemClick2'
},
columns: [
{
dataIndex: 'from',
text: 'From',
width: 140,
},
{
dataIndex: 'title',
text: 'Subject',
flex: 1,
},
{
xtype: 'datecolumn',
dataIndex: 'received_on',
width: 90,
text: 'Received On'
}
],
},
//////////////////////////////////////////////////////////
{
xtype: 'grid',
cls: 'allRecordsCls',
scrollable: false,
border: false,
title: 'Social',
routeId: 'inbox',
bind: '{inbox}',
listeners: {
itemclick: 'clickme'
},
selModel: {
selType: 'checkboxmodel',
checkOnly: true,
showHeaderCheckbox: true
},
headerBorders: false,
rowLines: false,
scrollable: false,
columns: [
{
dataIndex: 'from',
text: 'From',
width: 140,
},
{
dataIndex: 'title',
text: 'Subject',
flex: 1,
},
{
xtype: 'datecolumn',
dataIndex: 'received_on',
width: 90,
text: 'Received On'
}
],
},
///////////////////////////////////////////////////////
{
xtype: 'grid',
cls: 'allRecordsCls',
scrollable: false,
border: false,
title: 'Promotion',
routeId: 'inbox',
bind: '{inbox}',
selModel: {
selType: 'checkboxmodel',
checkOnly: true,
showHeaderCheckbox: true
},
listeners: {
itemclick: 'onGridCellItemClick2'
},
headerBorders: false,
rowLines: false,
scrollable: false,
columns: [
{
dataIndex: 'from',
text: 'From',
width: 140,
},
{
dataIndex: 'title',
text: 'Subject',
flex: 1,
},
{
xtype: 'datecolumn',
dataIndex: 'received_on',
width: 90,
text: 'Received On'
}
],
},
],
},
///////////////////////////////////////////
{
id: 'cardPanel',
xtype: 'emaildetails'
},
]
what to write in function in "onGridCellItemClick2" which is declared in controller

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'
},
]
});

Grid inside Tab

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 ]

I have made a layout of tab panel with extjs designer

I have made a layout of tab panel with extjs designer but its not displaying anything if I am running it.
Here's the code please help me :
Ext.onReady(function(){
Ext.BLANK_IMAGE_URL = 'extjs/s.gif';
Ext.onReady(function(){
MyTabPanelUi = Ext.extend(Ext.TabPanel, {
activeTab: 0,
width: 800,
height: 500,
title: 'Ledger',
itemId: 'ledger_tab',
initComponent: function() {
this.items = [
{
xtype: 'panel',
title: 'Ledger',
autoScroll: true,
items: [
{
xtype: 'editorgrid',
title: 'Ledger',
store: 'store',
height: 150,
footer: true,
stripeRows: true,
header: true,
loadMask: true,
id: 'leg_grid_up',
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'string',
header: 'Column',
sortable: true,
width: 100,
editor: {
xtype: 'textfield'
}
},
{
xtype: 'numbercolumn',
dataIndex: 'number',
header: 'Column',
sortable: true,
width: 100,
align: 'right',
editor: {
xtype: 'numberfield'
}
},
{
xtype: 'datecolumn',
dataIndex: 'date',
header: 'Column',
sortable: true,
width: 100,
editor: {
xtype: 'datefield'
}
},
{
xtype: 'booleancolumn',
dataIndex: 'bool',
header: 'Column',
sortable: true,
width: 100,
editor: {
xtype: 'checkbox',
boxLabel: 'BoxLabel'
}
}
],
tbar: {
xtype: 'toolbar',
height: 50,
items: [
{
xtype: 'container',
layout: 'column',
width: 794,
height: 43,
items: [
{
xtype: 'spacer',
width: 588,
height: 18
},
{
xtype: 'spacer',
width: 200,
height: 18
},
{
xtype: 'datefield'
}
]
}
]//toolbar items
}
},
{
xtype: 'container',
height: 70
},
{
xtype: 'editorgrid',
title: 'Ledger',
height: 150,
id: 'leg_grid_down',
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'string',
header: 'Column',
sortable: true,
width: 100,
editor: {
xtype: 'textfield'
}
},
{
xtype: 'numbercolumn',
dataIndex: 'number',
header: 'Column',
sortable: true,
width: 100,
align: 'right',
editor: {
xtype: 'numberfield'
}
},
{
xtype: 'datecolumn',
dataIndex: 'date',
header: 'Column',
sortable: true,
width: 100,
editor: {
xtype: 'datefield'
}
},
{
xtype: 'booleancolumn',
dataIndex: 'bool',
header: 'Column',
sortable: true,
width: 100,
editor: {
xtype: 'checkbox',
boxLabel: 'BoxLabel'
}
}
],
tbar: {
xtype: 'toolbar'
}
},
{
xtype: 'container'
}
]//ledger panel
}
];//this
MyTabPanelUi.superclass.initComponent.call(this);
}
});
});
});
You need to render it onto some HTML tag. You can use the renderTo property to render the panel onto the body tag or some div tag with an id set.
Let's assume you are planning to render to the body tag. You need to add renderTo : Ext.getBody(). The Ext.getBody method simply returns the body tag.
MyTabPanelUi = Ext.extend(Ext.TabPanel, {
activeTab: 0,
width: 800,
height: 500,
renderTo: Ext.getBody(),
.
.
.
You aren't rendering it.
Try rendering it to Ext.getBody():
MyTabPanelUi.render(Ext.getBody());

extjs - 'Store is undefined'

I'm pretty sure this a trivial problem and i'm just being a bit stupid. Your help would be hugely appreciated.
In controls/dashboard.js I have:
Ext.ill.WCSS.controls.dashboard = {
xtype:'portal',
region:'center',
margins:'35 5 5 0',
items:[{
columnWidth: 1,
style:'padding:10px',
items:[{
title: 'My Cluster Jobs',
layout:'fit',
html: "test"
}]
},{
columnWidth: 1,
style:'padding:10px',
items:[{
title: 'All Cluster Jobs',
iconCls: 'icon-queue',
html: "test",
items: new Ext.grid.GridPanel({
title: 'Cluster Job Queue',
store: Ext.ill.WCSS.stores.dashboardClusterJobs,
width: 791,
height: 333,
frame: true,
loadMask: true,
stateful: false,
autoHeight: true,
stripeRows: true,
floating: false,
footer: false,
collapsible: false,
animCollapse: false,
titleCollapse: false,
columns:[
{
xtype: 'gridcolumn',
header: 'Job ID',
sortable: true,
resizable: true,
width: 100,
dataIndex: 'JB_job_number',
fixed: false
},
{
xtype: 'gridcolumn',
header: 'Priority',
sortable: true,
resizable: true,
width: 100,
dataIndex: 'JAT_prio',
fixed: false
},
{
xtype: 'gridcolumn',
header: 'User',
sortable: true,
resizable: true,
width: 100,
dataIndex: 'JB_owner'
},
{
xtype: 'gridcolumn',
header: 'State',
sortable: true,
resizable: true,
width: 100,
dataIndex: 'state'
},
{
xtype: 'gridcolumn',
header: 'Date Submitted',
sortable: true,
resizable: true,
width: 100,
dataIndex: 'JAT_start_time'
},
{
xtype: 'gridcolumn',
header: 'Queue',
sortable: true,
resizable: true,
width: 100,
dataIndex: 'queue_name'
},
{
xtype: 'gridcolumn',
header: 'CPUs',
sortable: true,
resizable: true,
width: 100,
dataIndex: 'slots'
}
],
bbar: {
xtype: 'paging',
store: 'storeClusterQueue',
displayInfo: true,
refreshText: 'Retrieving queue status...',
emptyMsg: 'No jobs to retrieve',
id: 'clusterQueuePaging'
}
})
}]
}]
};
Simple enough, note the reference to 'Ext.ill.WCSS.stores.dashboardClusterJobs'
So in stores/dashboard.js I just have this:
Ext.ill.WCSS.stores.dashboardClusterJobs = new Ext.data.XmlStore({
storeId: 'storeClusterJobs',
record: 'job_list',
autoLoad: true,
url: 'joblist.xml',
idPath: 'job_info',
remoteSort: false,
fields: [
{
name: 'JB_job_number'
},
{
name: 'JAT_prio'
},
{
name: 'JB_name'
},
{
name: 'JB_owner'
},
{
name: 'state'
},
{
name: 'JAT_start_time'
},
{
name: 'slots'
},
{
name: 'queue_name'
}
]
});
I run the code and I get 'store is undefined' :S It's confusing me a lot. All of the javascripts have been included in the correct order.
i.e.
<script type="text/javascript" src="/js/portal.js"></script>
<script type="text/javascript" src="/js/stores/dashboard.js"></script>
<script type="text/javascript" src="/js/controls/dashboard.js"></script>
Thanks guys!
It might be a namespace issue. What do your Ext.ns declarations look like?
I think we need more info. You're using an xtype of portal (code missing) and it's not obvious how this object is instantiated (code missing).
I figured it out. It was to do with my ordering of javascript files. (ooops!) thanks so much for your help though and apologies for the late response.

Resources