grid-win-override.js
上传用户:snow1005
上传日期:2015-11-10
资源大小:3151k
文件大小:5k
源码类别:

Ajax

开发平台:

JavaScript

  1. /* Override the module code here.
  2.  * This code will be Loaded on Demand.
  3.  */
  4. Ext.override(QoDesk.GridWindow, {
  5. // Array data for the grid
  6. dummyData : [
  7.     ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
  8.     ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
  9.     ['American Express Company',52.55,0.01,0.02,'9/1 12:00am'],
  10.     ['American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am'],
  11.     ['AT&T Inc.',31.61,-0.48,-1.54,'9/1 12:00am'],
  12.     ['Caterpillar Inc.',67.27,0.92,1.39,'9/1 12:00am'],
  13.     ['Citigroup, Inc.',49.37,0.02,0.04,'9/1 12:00am'],
  14.     ['Exxon Mobil Corp',68.1,-0.43,-0.64,'9/1 12:00am'],
  15.     ['General Electric Company',34.14,-0.08,-0.23,'9/1 12:00am'],
  16.     ['General Motors Corporation',30.27,1.09,3.74,'9/1 12:00am'],
  17.     ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
  18.     ['Honeywell Intl Inc',38.77,0.05,0.13,'9/1 12:00am'],
  19.     ['Intel Corporation',19.88,0.31,1.58,'9/1 12:00am'],
  20.     ['Johnson & Johnson',64.72,0.06,0.09,'9/1 12:00am'],
  21.     ['Merck & Co., Inc.',40.96,0.41,1.01,'9/1 12:00am'],
  22.     ['Microsoft Corporation',25.84,0.14,0.54,'9/1 12:00am'],
  23.     ['The Coca-Cola Company',45.07,0.26,0.58,'9/1 12:00am'],
  24.     ['The Procter & Gamble Company',61.91,0.01,0.02,'9/1 12:00am'],
  25.     ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am'],
  26.     ['Walt Disney Company (The) (Holding Company)',29.89,0.24,0.81,'9/1 12:00am']
  27. ],
  28.     createWindow : function(){
  29.         var desktop = this.app.getDesktop();
  30.         var win = desktop.getWindow('grid-win');
  31.         
  32.         if(!win){        
  33.          var sm = new Ext.grid.RowSelectionModel({singleSelect:true});
  34.         
  35.          var grid = new Ext.grid.GridPanel({
  36. //autoExpandColumn:'company',
  37. border:false,
  38. ds: new Ext.data.Store({
  39. reader: new Ext.data.ArrayReader({}, [
  40. {name: 'company'},
  41. {name: 'price', type: 'float'},
  42. {name: 'change', type: 'float'},
  43. {name: 'pctChange', type: 'float'}
  44. ]),
  45. data: this.dummyData
  46. }),
  47. cm: new Ext.grid.ColumnModel([
  48. new Ext.grid.RowNumberer(),
  49. {header: "Company", width: 120, sortable: true, dataIndex: 'company'},
  50. {header: "Price", width: 70, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
  51. {header: "Change", width: 70, sortable: true, dataIndex: 'change'},
  52. {header: "% Change", width: 70, sortable: true, dataIndex: 'pctChange'}
  53. ]),
  54. shadow: false,
  55. shadowOffset: 0,
  56. sm: sm,
  57. tbar: [{
  58. text:'Add Something',
  59. tooltip:'Add a new row',
  60. iconCls:'demo-grid-add'
  61. }, '-', {
  62. text:'Options',
  63. tooltip:'Your options',
  64. iconCls:'demo-grid-option'
  65. },'-',{
  66. text:'Remove Something',
  67. tooltip:'Remove the selected item',
  68. iconCls:'demo-grid-remove'
  69. }],
  70. viewConfig: {
  71. forceFit:true
  72. }
  73. });
  74. // example of how to open another module on rowselect
  75. sm.on('rowselect',function(){
  76. //var tabWin = this.app.getModule('demo-tabs');
  77. //if(tabWin){
  78. // tabWin.launcher.handler.call(this.scope || this);
  79. //}
  80. }, this);
  81.             win = desktop.createWindow({
  82.                 id: 'grid-win',
  83.                 title:'Grid Window',
  84.                 width:740,
  85.                 height:480,
  86.                 iconCls: 'grid-icon',
  87.                 shim:false,
  88.                 animCollapse:false,
  89.                 constrainHeader:true,
  90. layout: 'fit',
  91.                 items: grid,
  92.                 taskbuttonTooltip: '<b>Grid Window</b><br />A window with a grid',
  93.                 tools: [
  94. {
  95. id: 'refresh',
  96. handler: Ext.emptyFn,
  97. scope: this
  98. }
  99. ]
  100.             });
  101.             
  102.             // begin: modify top toolbar
  103.         var tb = grid.getTopToolbar();
  104. // example of getting a reference to another module's launcher object
  105.         var tabWin;// = this.app.getModule('demo-tabs');
  106.         
  107. if(tabWin){
  108. var c = tabWin.launcher;
  109. tb.add({
  110. // example button to open another module
  111. text: 'Open Tab Window',
  112. handler: c.handler,
  113. scope: c.scope,
  114. iconCls: c.iconCls
  115. });
  116. }
  117. tb.add({
  118. text: 'Toggle My Taskbutton Text/Icon',
  119. handler: this.updateTaskButton,
  120. scope: this
  121. });
  122.         // end: modify top toolbar
  123.         
  124.         // could modify this windows taskbutton tooltip here (defaults to win.title)
  125.         //win.taskButton.setTooltip('Grid Window');
  126.         }
  127.         
  128.         win.show();
  129.     },
  130.     
  131.     updateTaskButton : function(){
  132.      var desktop = this.app.getDesktop(),
  133.      win = desktop.getWindow('grid-win'),
  134.      btn = win.taskButton;
  135.     
  136.      if(btn.getText() === 'Toggled'){
  137.      btn.setText('Grid Window');
  138.      // can pass in an object
  139.      btn.setTooltip({title: 'Grid Window', text: 'A window with a grid'});
  140.      // or could pass in a string
  141.      //btn.setTooltip('Grid Window');
  142.      btn.setIconClass('grid-icon');
  143.      }else{
  144.      btn.setText('Toggled');
  145.      btn.setTooltip({title: 'Toggled', text: 'You have toogled me'});
  146.      btn.setIconClass('bogus');
  147.      }
  148.     }
  149. });