dataTable render not working?

dataTable render not working?

randrewsrandrews Posts: 5Questions: 3Answers: 0
edited November 2017 in Free community support

Trying to render my datatable as text using " render: $.fn.dataTable.render.text() " to avoid running scripts within the table.
The datatable pulls data from the angularjs scope and runs in the angular controller.

Here is the code to define the datatable:

$scope.dt=angular.element('#allUsers').DataTable({
                data: $scope.allUsersDTData
            });

How can I get the render to work in the angular controller?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,461Questions: 1Answers: 10,466 Site admin
    edited November 2017

    Assuming you can initialise a DataTable like normal, then you should just be able to use columns.render like you would in any other environment. Have you tried using it as defined in the documentation?

    Allan

  • randrewsrandrews Posts: 5Questions: 3Answers: 0

    I'm using the following:

    $scope.dt=angular.element('#allUsers').DataTable({
                    data: $scope.allUsersDTData,
                    render: $.fn.dataTable.render.text()
                });
    

    This doesn't throw an error but when the datatable loads with something like "alert(1)" within the data it still runs meaning it throws the alert and doesn't render as text.

    Any ideas?

  • allanallan Posts: 63,461Questions: 1Answers: 10,466 Site admin
    Answer ✓

    There is no render option at the top level of DataTables' configuration options - its in the columns array of configuration options of the columns as shown in the columns.render documentation.

    Perhaps that isn't clear in the renderer documentation - I'll see about clearing that up.

    Allan

This discussion has been closed.