Ajax return formatted HTML

Ajax return formatted HTML

francescomazzurcofrancescomazzurco Posts: 1Questions: 1Answers: 0

Hello all,

I understand that DataTables can be initialized from an HTML table.
However, is it possible populate the DataTable from an ajax call which returns formatted HTML?
The response from the server would be a string looking like this:

<tr data-id="1">
  <td>1.1</td><td class="some-class">1.2/td>
</tr>
<tr data-id="1">
   <td>2.1</td><td class="some-class">2.2/td>
</tr>

I know I can add classes and other information to the row with the createdRow option, and similarly to the cells with the columns.className option, however my goal would be to do all of this processing on the server side, and just return plain html to be added to the table.

Looking at the javascript source code, I noticed an undocumented property, ajax.DataType, which can be set to "html". I tried this option, but had no success.

Thank you in advance.

Answers

This discussion has been closed.