Lookup other database

Lookup other database

bert@elektrus.bebert@elektrus.be Posts: 1Questions: 1Answers: 0

I want lookup to an other database for one column.
Why works the next code not? when i put an alert before the return, the alert give me the date from the variable datawagen.

 "render": function ( data, type, row, meta) {
                    
                    $.post('ajax/detailwagen.php', {wagenid: data}, function(datawagen){
                    
                    return datawagen;
                    })

Answers

  • rpmccormickrpmccormick Posts: 136Questions: 18Answers: 0

    That should work, but it would have horrible performance. You do not want to fire an AJAX request every time each row is rendered!

    What you need to do is edit the php file for the table and use ->join() to add the column from the other database. You could also create a db VIEW with all the columns for your table, and then point the DT php to the VIEW. The VIEW approach has some advantages, but its disadvantage is that Editor New and Delete will not work (but Edit will, and DT display will, and you have a db view that matches your table perfectly optimizing the json speed)

This discussion has been closed.