page.jumpToData() not working when fetching data with AJAX

page.jumpToData() not working when fetching data with AJAX

DonMikoneDonMikone Posts: 3Questions: 1Answers: 1
edited June 2017 in Free community support

Hey everyone!

I am using the page.jumpToData() plug-in and figured there is a bug(?) when fetching the rows via AJAX. In this case I cannot use page.jumpToData() in order to jump to a particular row / data set. However, when I filled my table via HTML (as <tr></tr>) the function worked just as expected. Did anyone experience similar issues with this plug-in? I'd appreciate any kind of help here. Thank you!

Here's the JS-code of the table's initialization:

$('#datatable-main').DataTable({
            language : {
                url : "{% static 'datatables/js/German.json' %}" // Django url
            },
            "ajax": "{% url 'get_data_json' %}", // Django url
            "responsive" : true,
            columnDefs : [{
                "orderable" : false,
                "targets" : 4
            },
            {
                "targets": 5,
                "className": "never",
                "visible": false,
                "searchable": false
            }],
            "initComplete": function(settings, json) {
                this.api().page.jumpToData('Some row', 5);
            }
        });

Cheers
Mike

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin

    I'm not aware of an issue with that. Could you link to a page showing the issue so I can check it out please?

    Allan

  • DonMikoneDonMikone Posts: 3Questions: 1Answers: 1

    Hey Allan!

    Thanks for the quick reply. I fabricated a minimal example using the same initialization code but different data since my production data is sensitive. Now it works perfectly.
    This issue may be due to the formatting of my data... I'll keep you posted.

    Thank you very much!

  • DonMikoneDonMikone Posts: 3Questions: 1Answers: 1
    Answer ✓

    Ooooh! Stupid mistake! I figured out what went wrong. :)

    I passed a string as the first (search) parameter to page.jumpToData(). However, my search column was filled with integer objects. Now it works like a charm.

    I am really sorry for having bothered you. Keep up the good work.
    This question can be marked as answered.

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin

    Thanks for posting back - great to hear you've got it working now.

    Allan

This discussion has been closed.