Datatable Javascript stops working around 250 entries

Datatable Javascript stops working around 250 entries

ssm87ssm87 Posts: 4Questions: 1Answers: 0
edited May 2016 in Free community support

I'm using datatables to list PubMed articles from within the previous X months. Here's a screenshot: https://ibin.co/2h1Rxk7UueTo.png As you can see, everything works for up to 202 entries; the javascript displays the download buttons, the search box, the show X entries and the pagination.

However, when I search for PubMed articles from the previous 7 months (255 entries), the javascripts stops working. No search box, no show X entries, no pagination, etc. Instead, the datatable displays all 255 entries on a single page. Here's a screenshot: https://ibin.co/2h1U243n8aLG.png

Did anyone else have this error?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,794Questions: 1Answers: 10,513 Site admin

    Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.

    Information on how to create a test page, if you can't provide a link to your own page can be found here.

    Thanks,
    Allan

  • ssm87ssm87 Posts: 4Questions: 1Answers: 0
    edited May 2016

    Hi Allan, thanks for getting back to me.

    Here's a link to my page: https://pubmed-search-v3-ssm87-1.c9users.io/.
    Here's a link to the files: https://preview.c9users.io/ssm87/pubmed_search_v3/.

    Thanks,
    ssm87

  • allanallan Posts: 63,794Questions: 1Answers: 10,513 Site admin

    Can you tell me what I need to search for in order to trigger the error please. The default search returns 37 rows and that appears to work.

    Allan

  • ssm87ssm87 Posts: 4Questions: 1Answers: 0

    If you search for keyword 'ataxia' and months '7' then you get the error. It should return 260 entries but the javascript for datatable no longer works.

  • allanallan Posts: 63,794Questions: 1Answers: 10,513 Site admin
    Answer ✓

    There is a Javascript error showing on the console:

    jquery.dataTables.min.js:24 Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined

    Looking at the response HTML in Chrome's network tools I can see that the final few lines returned from the server are:

          <tr>
            <td class="counter">258</td>
            <td class="name">Hypoxia-Targeted Drug Q6 Induces G2-M Arrest and Apoptosis via Poisoning Topoisomerase II under Hypoxia.</td>
            <td class="born"><a href='http://www.ncbi.nlm.nih.gov/pubmed/?term=26649750 ' target='_blank'>click here</a></td>
            <td class="name">In spite of the tremendous efforts dedicated to developing hypoxia-activated prodrugs, no agents yet have been approved for clinical therapy. In the present study, the hypoxic selective anti-cancer activity as well as the cellular target of a novel tirapazamine (TPZ) analogue, 7-methyl-3-(3-chlorophenyl)-quinoxaline-2-carbonitrile 1,4-dioxide (Q6) were investigated. Q6 implemented anti-cancer effects via poisoning topoisomerase II (topo II) under hypoxia. Modified trapped in agarose DNA immunostaining (TARDIS) assay showed more topo II-DNA cleavage complexes trapped by Q6 than TPZ at even lower concentration. In addition, by introducing <font color='red'><b>ataxia</b></font>-telangiectasia-mutated (ATM) kinase inhibitors caffeine and KU-60019, we displayed that Q6-triggered apoptosis was attributed, at least partially, to DNA double-strand breaks generated by the topo II-targeting effect. Collectively, Q6 stood out for its better hypoxia-selectivity and topo II-poisoning than the parental compound TPZ. All these data shed light on the research of Q6 as a promising hypoxia-activated prodrug candidate for human hepatocellular carcinoma therapy.</td>
          </tr>
          <tr>
          </tr>
        </tbody>
      </table>
    </div>
    

    Note on lines 7 and 8 how there is an empty tr element. That is the issue - DataTables can't find any data in that row, and therefore it throws an error.

    In order to address this error you need to remove that empty row from the returned HTML. I'm not sure why the server would be putting an entering an empty row into the HTML - perhaps empty data from the database, or an incorrect for in loop.

    Allan

  • ssm87ssm87 Posts: 4Questions: 1Answers: 0
    edited May 2016

    Thanks Allen! There was an error in my for loop.

This discussion has been closed.