olifolkerd / tabulator

Interactive Tables and Data Grids for JavaScript
http://tabulator.info
MIT License
6.71k stars 818 forks source link

html tag (link, span, etc.. ) in existing html table #554

Closed TORION84 closed 7 years ago

TORION84 commented 7 years ago

Hi , first of all thank you for the great work. I noticed a bug: if in the <td> tag is present html code (eg between <a> or <span>) in the tabulator it isn't "render".

olifolkerd commented 7 years ago

Hey,

Thanks for getting in touch and thanks for your kind words.

Are you referring to a td tag inside an anchor tag or span?

<span>
    <td></td>
</span>

If so then im afraid the reason that isnt working is because that isn't technically valid HTML, some browsers support invalid syntax's to help give the best view possible regardless of circumstance, but Tabulator can only parse for valid HTML syntax when building a table.

If i have got the wrong end of the stick here, could you post a sample copy of the html you are trying to parse?

Cheers

Oli

TORION84 commented 7 years ago

No like this

 <table>
  <thead> <tr><th>link</th><th>data</th></tr></thead>
  <tbody>
     <tr><td><a>link 01</a></td><td><span>data 01</span></td></tr>
     <tr><td><a>link 02</a></td><td><span>data 02</span></td></tr>
  </tbody>
</table>

In the first column it writes <a>link 01</a> and in the second it writes <span>data 01</span>

olifolkerd commented 7 years ago

Ahh i see what you mean,

To prevent code injection into tables Tabulator automatically sanitized the data to plain text, if you want the text to display as HTML you should set the formatter for that column to html

Let me know if that helps

Cheers

Oli

TORION84 commented 7 years ago

Ok but I must write formatter for each column or can I write in the header of html table?

olifolkerd commented 7 years ago

it must be included in any column that contains html you want to show in the Tabulator, you can either include it in the column definition or in the header elements for each of the columns using the following tag property:

<th tabulator-formatter="html">Column Name</th>

Cheers

Oli

TORION84 commented 7 years ago

Thank you for your support :)