2017-08-08 95 views
0

我使用現代工具包與extjs 6.5.1。 我想在網格單元格中使用renderer屬性來使用html。渲染器只返回'<a>...</a>',但是當我使用它時,它將編碼html代碼,以便單元顯示'<a>...</a>'而不是鏈接。 關於在這個線程上的答案,我將需要一個單元屬性與「encodeHtml」轉爲false,但只要我添加一個單元格屬性渲染器將不會執行了(即使當我使用EncodeHtml),並顯示像那樣的數據沒有渲染器屬性。 爲什麼不能再使用渲染器屬性?extjs渲染器未執行

繼承人我的代碼:

{ 
    xtype: 'gridcolumn', 
    renderer: function(value, record, dataIndex, cell, column) { 
     console.log('hello world'); 
     return '<a>...</a>'; 
    }, 
    width: 30, 
    text: '...', 
    cell: { 
     xtype: 'textcell', 
     encodeHtml: false 
    } 
} 

What it looks like without encodeHtml

回答

0

此行爲是因爲你首先指定

cell: { 
    xtype: 'textcell' 
} 

。只要將其刪除,並且您的renderer可以返回HTML。這應該工作:

{ 
    xtype: 'gridcolumn', 
    renderer: function(value, record, dataIndex, cell, column) { 
     console.log('hello world'); 
     return '<a>...</a>'; 
    }, 
    width: 30, 
    text: '...' 
} 

至少ID確實在我的應用程序,在這裏我用renderer錢回來了HTML生成特殊格式。

如果需要指定cell財產,因爲是你沒有在你的代碼顯示,使用默認cellxtype代替:gridcell

+0

我需要encodeHtml屬性的單元屬性,這是必需的,否則呈現器將返回純文本,在單元格中顯示' ...'而不是鏈接。當我使用Sencha架構師時,我不能將xtype更改爲gridcell。 –

+0

我能夠通過操作代碼將xtype手動更改爲gridcell。謝謝您的幫助! –