Ext.BLANK_IMAGE_URL = '/lib/resources/images/default/s.gif'; /* * Ext JS Library 2.0 * Copyright(c) 2006-2007, Ext JS, LLC. * licensing@extjs.com * * http://extjs.com/license */ Ext.onReady(function(){ // second tabs built from JS var Russia = [ ['ATS (Amphetamine)',198,0,165.7,254,288,230], ['Cannabis Group',0,0,0,0,37865,0], ['Cannabis oil',0,0,0,0,0,647], ['Cocaine',109,17,157.6,76.8,92,266], ['Hashish',2101,1893,1695.8,1699.8,3984,2867], ['Heroin',4676,2445,2932.7,3442.8,3152,2637], ['Marijuana',30618,23742,26865.4,25138.7,33393,35887], ['Morphine',5,4,5.6,5.6,0,0], ['Opium',1523,535,362.7,439,0,0], ['Other',267,3009,0,0,72,740], ['Poppy straw (kuknar)',0,2543,1575.8,1851.4,2807,2867], ['Precursors',0,0,350147,7446,4318,0], ['Unspecified',75380,66035,0,0,0,0] ]; function addCommas(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ' ' + '$2'); } return x1 + x2; } function ifZero(val){ var d=val.toFixed(2); if(val > 0){ return addCommas(d); }else if(val <= 0){ return 'n/a'; } return val; } var myReader = new Ext.data.ArrayReader({},[ {name: 'Drug_Type'}, {name: '2005', type: 'float'}, {name: '2006', type: 'float'}, {name: '2007', type: 'float'}, {name: '2008', type: 'float'}, {name: '2009', type: 'float'}, {name: '2010', type: 'float'} ]); var tabs2 = new Ext.TabPanel({ renderTo: "myDiv", activeTab: 0, width:600, height:400, plain:true, defaults:{autoScroll: false}, items:[{ xtype: 'grid', title: 'Russia', store: new Ext.data.Store({data: Russia, reader: myReader}), columns: [ {header: 'Drug Type', width: 125, hideable: false, sortable: true, dataIndex: 'Drug_Type'}, {header: '
2005
', width: 75, align: 'right', hideable: false, sortable: true, renderer: ifZero, dataIndex: '2005', type: 'float'}, {header: '
2006
', width: 75, align: 'right', hideable: false, sortable: true, renderer: ifZero, dataIndex: '2006', type: 'float'}, {header: '
2007
', width: 75, align: 'right', hideable: false, sortable: true, renderer: ifZero, dataIndex: '2007', type: 'float'}, {header: '
2008
', width: 75, align: 'right', hideable: false, sortable: true, renderer: ifZero, dataIndex: '2008', type: 'float'}, {header: '
2009
', width: 75, align: 'right', hideable: false, sortable: true, renderer: ifZero, dataIndex: '2009', type: 'float'}, {header: '
2010
', width: 75, align: 'right', hideable: false, sortable: true, renderer: ifZero, dataIndex: '2010', type: 'float'}], viewConfig: { forceFit: true} }]//items end });//tabPanel end; });//Ext.onReady function end; /** */