Loading child row using ajax

Loading child row using ajax

BJW86BJW86 Posts: 30Questions: 11Answers: 0

Im having some trouble loading data in a child row using ajax, could anyone point me in the right direction?

http://live.datatables.net/rorajona/1/edit

Thanks,
Bruce

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,205Questions: 26Answers: 4,927

    Here is the ajax code to load the child data:

        $.ajax( {
        method: 'GET',
            url: "'http://localhost:3000'+Link",
            dataSrc: '',
            success: function (data) {   
    

    First dataSrc: '', is not an option for jQuery ajax() so it can be removed. Its not the problem though.

    The problem is with url: "'http://localhost:3000'+Link",. Your data has this object {data: 'Link', title: 'Link'}. To access this in the format function you need to use this instead:

    url: "http://localhost:3000" + rowData.Link,
    

    Depending on what rowData.Link contains you may or may not need to add a slash after 3000, for example: "http://localhost:3000/" + rowData.link.

    Kevin

  • BJW86BJW86 Posts: 30Questions: 11Answers: 0

    Brilliant, thank you very much Kevin.

    I have the data I am after now, the only thing is the + icon seems to have disappeared and when the data loads the child row is opening very wide, can I fix this in the CSS?

    Thanks again.
    Bruce

  • BJW86BJW86 Posts: 30Questions: 11Answers: 0

    Ive also noticed if I turn the paging off or increased the number of rows, the green icon comes back but it seems to break the child row so it won't work at all.. is there a way to turn off paging but keep the child row working?

    Thanks
    Bruce

  • allanallan Posts: 63,281Questions: 1Answers: 10,425 Site admin
    Answer ✓

    Most likely you are having a problem with Responsive and your custom child row controls trying to use the same elements to control the same icons.

    I guess the question becomes - do you need both? If not, remove the responsive class from the table. That would be a good check to make sure I'm on the right track anyway.

    Allan

  • allanallan Posts: 63,281Questions: 1Answers: 10,425 Site admin

    I meant to add this as well - if you don't need Responsive controlling the child rows, but you do want it to hide columns as the browser window gets smaller see this example.

    Allan

  • BJW86BJW86 Posts: 30Questions: 11Answers: 0

    Sorted, thanks Allan

    Bruce

Sign In or Register to comment.