2015-11-22 41 views
1

我使用FooTable(http://fooplugins.github.io/FooTable/docs/getting-started.html)從我的靜態html表格創建一些動態表格。停止FooTable從轉換單元格時從​​剝離html標記

在表格的單元格或標籤中,用於格式化單元格中的值。例如,我在一個單元中使用bootstraps標籤組件。

我遇到的問題是,當footable運行時,它會轉換所有的html格式,並且似乎從單元格中去掉所有這些html標籤,而我只剩下文本。

因此,例如,我可能有一個單元格:

<td><span class="label label-default">Default</span></td> 

轉換過來:

<td>Default</td> 

我的問題是有一個選項,以阻止這種情況發生?我有搜索谷歌和有關文件,但我沒有運氣。

似乎沒有很多人有這個問題。但肯定有人知道它是否可能。

+0

已經看到了這個解決方案? – FrontDev

回答

1

您是否嘗試過創建自己的格式化程序?

jQuery(function($){ 
    $('.table').footable({ 
     "columns": [{ 
      "formatter": function(value){ 
       return value; 
      } 
     }] 
    }); 
}); 

這似乎有點多餘,但它確實有一個默認的「類型」格式化所以也許只是路過值伸直背部沒有任何額外的UKNOWN巫術會解決這個問題。

5

您可以嘗試將列標識爲HTML,在具有HTML的列中使用data-type="html"

例子:

  <table id="testTable" class="table" data-paging="true"> 
      <thead> 
       <tr> 
        <th style="width: 45%">Origin</th> 
        <th data-breakpoints="sm xs" style="width: 45%">Destination</th> 
        <th style="width: 5%" data-type="html">&nbsp;</th> 
       </tr> 
      </thead> 
      <tbody> 
       <tr> 
        <td>O1</td> 
        <td>D1</td> 
        <td><span class="glyphicon glyphicon-remove"></span>&nbsp;<span class="glyphicon glyphicon-pencil"></span></td> 
       </tr> 
       <tr> 
        <td>O2</td> 
        <td>D2</td> 
        <td><span class="glyphicon glyphicon-remove"></span>&nbsp;<span class="glyphicon glyphicon-pencil"></span></td> 
       </tr> 
       <tr> 
        <td>O3</td> 
        <td>D3</td> 
        <td><span class="glyphicon glyphicon-remove"></span>&nbsp;<span class="glyphicon glyphicon-pencil"></span></td> 
       </tr> 
      </tbody> 
     </table> 

的Javascript:

$("#testTable").footable();