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 Pakistan = [ ['Acetic anhydride',0,0,0,16385,5126,0], ['Acetone',0,0,0,12,0,0], ['Ecstasy',0,0,0,0,132,0], ['Hashish',78942,115443,101068,134622,0,0], ['Heroin',2062,2819,2880,1900.36,2016,0], ['Morphine',21937,32657,10856,7324.89,1961,0], ['Opium',6140,8907,15362,27242.6,24819,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: 'Pakistan', store: new Ext.data.Store({data: Pakistan, 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;