/*
* Example windows
*/
Mydesktop. gridwindow1 = ext. Extend (ext. App. module ,{
ID: 'grid-win-money ',
Init: function (){
This. launcher = {
Text: 'historical exhibition status ',
Iconcls: 'icon-grid ',
Handler: This. createwindow,
Scope: This
}
},
Createwindow: function (){
VaR desktop = This. App. getdesktop ();
VaR win = desktop. getwindow ('grid-win-money ');
If (! Win ){
Win = desktop. createwindow ({
ID: 'grid-win-money ',
Title: 'historical exhibition status ',
Width: 740,
Height: 480,
Iconcls: 'icon-grid ',
Shim: false,
Animcollapse: false,
Constrainheader: True,
Layout: 'fit ',
Items:
New Ext. Grid. gridpanel ({
ID: 'grid-win-money-panel ',
Border: false,
Pageindex: 1,
Counts: 100,
Pagecounts: 10,
Store: New Ext. Data. Store ({
Data: jsondata. getdata (1 ),
Reader: New Ext. Data. jsonreader ({root: "detail "},[
{Name: 'company '},
{Name: 'price', type: 'float '},
{Name: 'change', type: 'float '},
{Name: 'fchang', type: 'float '}
])
}),
CM: New Ext. Grid. columnmodel ([
New Ext. Grid. rownumberer (),
New Ext. Grid. checkboxselectionmodel (),
{Header: "company", width: 120, sortable: True, dataindex: 'company '},
{Header: "price", width: 70, sortable: True, Renderer: Ext. util. format. usmoney, dataindex: 'price '},
{Header: "change", width: 70, sortable: True, dataindex: 'change '},
{Header: "change again", width: 70, sortable: True, dataindex: 'fchang '}
]),
Viewconfig :{
Forcefit: True
},
// Autoexpandcolumn: 'company ',
Tbar :[{
Text: 'add ',
Iconcls: 'add ',
Handler: function () {jsondata. Add ('grid-win-money-panel ');}
}],
Bbar: [{text: 'homepage', iconcls: 'x-tbar-page-First ',
Handler: function () {page. firstpage ('grid-win-money-panel ');}
},'-',
{Text: 'preview', iconcls: 'x-tbar-page-prev ',
Handler: function () {page. prevpage ('grid-win-money-panel ');}
},'-',
{Text: 'Next page', iconcls: 'x-tbar-page-next ',
Handler: function () {page. nextpage ('grid-win-money-panel ');}
},'-',
{Text: 'Last page', iconcls: 'x-tbar-page-last ',
Handler: function () {page. lastpage ('grid-win-money-panel ');}
},'-',
{Text: 'refresh', iconcls: 'x-tbar-page-refresh ',
Handler: function () {page. refreshpage ('grid-win-money-panel ');}]
}
)
});
}
Win. Show ();
// Add a selection operation to the grid control
VaR moneygridpanel = ext. getcmp ("Grid-win-money-panel ");
VaR rightclick = new Ext. menu. menu ({ID: 'rightclickcont', items: [{ID: 'rmenu1', Handler: function () {jsondata. view ('grid-win-money-panel ')},
Text: 'view'
}, {ID: 'rmenu2 ', Handler: function () {jsondata. Update ('grid-win-money-panel ');},
Text: 'modify', iconcls: 'option'
}, {ID: 'rmenu3', Handler: function () {jsondata. Del ('grid-win-money-panel ');},
Text: 'delete', iconcls: 'delete'}]
});
Moneygridpanel. addlistener ('cellclick', cellclick );
Function cellclick (moneygridpanel, rowindex, columnindex, e ){
VaR record = moneygridpanel. getstore (). getat (rowindex );
VaR fieldname = moneygridpanel. getcolumnmodel (). getdataindex (columnindex );
VaR DATA = record. Get (fieldname );
Rightclick. showat (E. getxy ())
}
//
}
});
// Paging Sharing Method
VaR page = {
Nextpage: function (GID ){
VaR extpage = ext. getcmp (GID );
If (extpage. pageindex <extpage. pagecounts)
Extpage. pageindex ++;
Extpage. getstore (). loaddata (jsondata. getdata (GID, extpage. pageindex ,''));
},
Prevpage: function (GID ){
VaR extpage = ext. getcmp (GID );
If (extpage. pageindex> 1)
Extpage. pageindex --;
Extpage. getstore (). loaddata (jsondata. getdata (GID, extpage. pageindex ,''));
},
Firstpage: function (GID ){
VaR extpage = ext. getcmp (GID );
Extpage. getstore (). loaddata (jsondata. getdata (GID, 1 ,''));
},
Lastpage: function (GID ){
VaR extpage = ext. getcmp (GID );
Extpage. getstore (). loaddata (jsondata. getdata (GID, extpage. pagecounts ,''));
},
Refreshpage: function (GID ){
VaR extpage = ext. getcmp (GID );
Extpage. getstore (). loaddata (jsondata. getdata (GID, extpage. pageindex ,''));
}
}
// Sharing methods for different data operations
VaR jsondata = {
Getdata: function (GID, pageindex, keys ){
If (pageindex = 1)
Return Ext. Grid. jsondata;
Else
Return Ext. Grid. jsondata2;
},
Add: function (GID) {alert ('add ');},
View: function (GID) {alert ('view ');},
Update: function (GID) {alert ('update ');},
DEL: function (GID) {alert ('del ');}
}