2013-06-19 35 views
-1

我是Extjs的新手。我試圖在新的瀏覽器窗口中打開日誌文件,當我點擊Extjs 4中的網格面板中的按鈕時,我可以下載該文件。但我不想下載它,我希望它應該在新的瀏覽器窗口中打開時,我點擊該按鈕。我這樣做:如何在extjs的網格面板中打開新的瀏覽器窗口onclick 4

   xtype: 'gridpanel', 
      id: 'logResultGrid', 
       margin: '40 0 10 20', 
       width: 439, 
       title: 'Logs Result:', 
      store: 'LogsStore', 
      viewConfig: { 
      id: 'logsGrid' 
       }, 
      columns: [ 
      { 
      xtype: 'gridcolumn', 
    renderer: function(value, metaData, record, rowIndex, colIndex, store, view) { 
     var directoryName= Ext.getCmp('logsJobName').getValue(); 

return''+ value +''; }, 寬度:297, dataIndex: '文件名', 文本: '登錄名稱' }, { 的xtype: 'actioncolumn', 寬度:116, 項目:[ { 處理程序:功能( view,rowIndex,colIndex,item,e)var my_record = view.getSelectionModel()。getLastSelected();

 var directoryName= Ext.getCmp('logsJobName').getValue(); 
                          var rec = Ext.StoreMgr.lookup("LogsStore").getAt(rowIndex); 
                         var my_url = 'http://localhost:40889/Snowy/fileDownload/download.htm?reportName='+rec.data.fileName+'&directoryName='+directoryName; 

    // new Ext.Window({ 
                           // width: 500, 
                           // height: 500, 
                           // html: '<iframe width="300" height="300" src="' + my_url + '"</iframe>' 
                          // }).show(); 

                         window.open(my_url,"_blank"); 
                          //}); 
                         }, 
                    icon: 'resources/images/Open-Folder-Info-icon.png' 
     } 
    ] 
    } 
], 
    selModel: Ext.create('Ext.selection.CheckboxModel', { 

           }) 
                    } 
                   ] 
                  } 
                 ] 
                } 

通過做上述,我可以下載file.I現在用渲染器下載file.To打開我使用的處理器新的瀏覽器窗口中的文件。我使用java作爲我的後端。如果我在這做錯了,請糾正我。我過去兩天以來一直在掙扎。提前致謝。

+1

您是否在Extjs文檔中搜索了示例:http://docs.sencha.com/extjs/4.2.1/? – xpereta

回答

4

你應該只能夠使用普通的JavaScript來實現這一目標:

{ 
    xtype: 'button', 
    text: 'Open Log', 
    handler: function() { 
     window.open('myLog.txt'); 
    } 
} 
0

是否要下載的文件或在新窗口中打開是由用戶決定的行爲。 如果您想強制查看pdf,您可以使用pdf查看器插件。

相關問題