Deferred loading and initial data formatting
Deferred loading and initial data formatting
I've run into an issue with deferred loading and html characters in the data. I'm not sure if this is a bug or a problem with how I'm initializing the table. One thing slightly out of the ordinary I'm doing is using data attributes to pass all configuration into the table. I'm then using a generic helper that reads the data attributes and activates the table. The initial page of data is passed with the layout. If the data contains special characters (such as HTML tags) then I have problems with the initial data vs data that is brought down from the server with page changes.
If the data has any HTML markup in it (such as a closing "</td>") and I don't have the data HTML encoded then I end up with broken page markup. If I do have the data HTML encoded the row callback function sees different results from the initial page processing vs. later pages loaded via a server callback.
First off, here is a snipet of the initial table on the page:
<table id="dtable" class="table dataTable table-striped table-bordered dt-responsive" style="display: none; width: 100%" data-order="[[1, "asc"]]" data-cdt-length="10" data-cdt-filtered="26" data-cdt-total="26">
<thead>
<tr>
<th data-data="Id">Id</th>
<th data-data="Name">Name</th>
<th data-data="RecordType">Record Type</th>
<th data-data="DetailLink" data-visible="false" />
</tr>
</thead>
<tbody>
<tr>
<td>4950</td>
<td>AAA Name <b>bold</b></td>
<td>Primary</td>
<td>/DataAccess/Details/4950</td>
</tr>
And here is what my row callback function looks like:
function updateRow(row, data) {
$('td:eq(1)', row).html('<a href="' + data.DetailLink + '">' + $.HtmlEncode(data.Name) + '</a>');
}
When the page first loads, the value is being displayed as "AAA Name <b>bold</b>
". If I change pages away and then return to that page I then see "AAA Name <b>bold</b>
".
It looks like the data stored in the HTML table is being taken raw to the row callback function instead of treating it as escaped text. This makes it impossible to pass in any text that contains embedded markup. If the "td" value isn't encoded then it is possible to store broken markup.
So, after all that, is there a way to tell the deferred loading process that the data stored in the HTML is encoded/escaped instead of taking the raw values?
Answers
Hi @StuffOfInterest ,
There's a lot of unusual stuff going on there - this will be one of those problems where the devil is in the detail. We're happy to take a look, but it would help if you could link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin