2011-08-13 28 views
0

我正在使用一個網格面板,在該面板中我需要將一列作爲鏈接​​(它應該看起來像鏈接而不需要任何操作)。我在網格面板中使用偵聽器,並單擊其工作正常的單元格。只有第一列應該看起來像一個鏈接。但如何把href =「#」我不確定。這是我的代碼:如何使用href作爲Ext Grid Panel中的列

var addressDetailsStore = Ext.create('Ext.data.Store', { 
    id:'addressDetailsStore', 
    autoLoad: true, 
    fields: 
    [ 
    'addressType', 
    'street1', 
    'street2', 
    'province', 
    'city', 
    'country' 
    ], 
    proxy: { 
     type: 'ajax', 
     url: 'resources/json/addressDetails.json', // url that will load data with respect to start and limit params  
     reader: { 
      type: 'json', 
      root: 'items', 
     } 
    } 


}); 

Ext.define('iOMS.view.common.addressView', { 
extend: 'Ext.grid.Panel', 
alias: 'widget.AddressViewPanel', 
    layout: 'fit', 
    collapsible: true, 
    title:'Address', 

    store: addressDetailsStore, 
    listeners:{ 
       cellclick:function (iView, iCellEl, iColIdx, iRecord, iRowEl, iRowIdx, iEvent){ 
// Getting the event and I am doing logic here.. 

}

我只是想「地址類型」列看起來像一個鏈接,我不知道在哪裏把HREF ... 感謝您的答覆。 -Praveen

回答

3

您可以指定所需的列,並且對於僅包含鏈接的列添加呈示器。這個例子可能對你有幫助。

var template = new Ext.XTemplate(
     '<a href="#"> </a>').compile(); 

columns:[ 
      { 
       header: "", 
       renderer: function() { 
        return template.applyTemplate(); 
       } 
      }, 
5

你也可以使用一個模板列:

columns: [ 
    { text: 'External Link', xtype: 'templatecolumn', tpl: '<a href="{url}">{title}</a>'} 
] 
0

您可以使用渲染器之類的函數如下

columns: [ 
     { 
      header: 'number', 
      dataIndex: 'number', 
      flex: 1, 
      renderer: function(number) { 
       return Ext.String.format('<a href="#users/{0}">{0}</a>', number); 
      } 
     },