jbox-web / ajax-datatables-rails

A wrapper around DataTable's ajax methods that allow synchronization with server-side pagination in a Rails app
MIT License
585 stars 228 forks source link

How to display HTML that is returned as part of the get_raw_records method? #361

Closed ianbradbury-bizzibody closed 4 years ago

ianbradbury-bizzibody commented 4 years ago

The query returned from the database includes a column that contains HTML witch is then escaped by the Datatables code. Is it possible to present the value as HTML?

I have tried:

data method - appending .html_safe to the records mapping.

   {
   members: record.members.html_safe,
   DT_RowId: record.id
   }

I've also tried using raw()

Any tips/ideas?

ianbradbury-bizzibody commented 4 years ago

Not to worry - I found the answer.

members: record.members.to_s.html_safe,

The trick was to ensure the value was a string and then use html_safe.