Rendering on page 2

Rendering on page 2

labelistenlabelisten Posts: 1Questions: 1Answers: 0

I'd like to replace the content of a column with ajax-content (it's a PHP-script which calculates a SVG-Image). It works already perfect on the first page, but not on the following pages. Only, when I change something and the table gets refreshed and the SVG is shown.

So I have the function for the Image

function svgImage(thisID) {
                    $.ajax({
                        url: "ajax/svgimage.php?type=thumb&id="+thisID+"&width="+window.innerWidth+"&height="+window.innerHeight,
                        dataType: "html",
                        cache: true,
                        success: function(result) {
                            $('#row_'+thisID+" td:first-child").html(result)
                        }
                    })
                }

And the dataTable Init:

                table = $('#etiketten').DataTable( {
                    ajax:   {
                        url: "json/etiketten.php?IDkunden=<?=$_SESSION["user"]["IDkunden"]?>",
                        cache:  true
                        },
                    columns: [
                        {
                            data: function(data) {
                                svgImage(data.thisID)
                                return data
                                },
                            orderable: false,
                        clickable: false
                        },

I know the FAQ - but this isn't an Event. Or is it?! Thanks, Frank!

Answers

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,770

    Can you post a link to your page or a test case showing the issue? Without actually seeing the problem it will be hard to diagnose and offer suggestions.

    I would say that using an Ajax request for each row, as its drawn, is not efficient. This may or may not be the problem. Do some debugging of your script to see what happens with these requests hen you go to page 2.

    Would it be possible to fetch all the data that svgImage() fetches and store in aa Javascript variable that you can access when displaying the rows?

    Kevin

This discussion has been closed.