HTML links to images in table data, suppress GET request

HTML links to images in table data, suppress GET request

cranworthcranworth Posts: 20Questions: 10Answers: 0
edited September 2015 in DataTables 1.10

Dear all,

I have the following instantiation of a Datatable:

 var data_table = $('#guideline_entries').DataTable({
    data: table_data, 
    dom: "Tfrtip",
    columns: [ 
      {data: null, defaultContent: '', orderable: false, "visible": false },    /*  data-id column */ 
      {data: 'title', 'width': '100%'}, 
      {data: 'html', "visible": false}
    ],
    order: [ 1, 'asc' ],
    tableTools: {
        sRowSelect: "os",
        sRowSelector: 'td',
        sSwfPath: '../datatable/DataTables-1.10.0/extensions/TableTools/swf/copy_csv_xls_pdf.swf',
        aButtons: [

        ]
    }
  });

The data for the table is contained within the javascript variable table_data.

The issue, i am facing, is with column html that is meant to hold HTML content. In the HTML content, if there are links to images such as:

<img src="some_image.png" />

The Datatable, while loading, tries to fetch the image content, even though the column's visible is set to false. I can see this in Chrome's debugger where there is a failed GET request for the image.

Is there a way to suppress the Datatable from issuing a GET request to fetch images when the table's data contains HTML links to images? Especially in this example, where the column is not visible and thus no rendering is required.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,696Questions: 1Answers: 10,500 Site admin
    Answer ✓

    This is something that I think is probably up to the browser rather than DataTables. DataTables will not insert the element into the document if the column visibility is hidden, but it will create the element. That I guess is enough for the browser to request the image.

    If you don't want the HTML and the column isn't going to be visible, why define that column at all? Just remove the last entry in your columns array.

    Allan

This discussion has been closed.