How to add hyperlink in my DataTables to update my data.

How to add hyperlink in my DataTables to update my data.

MjohnMjohn Posts: 1Questions: 1Answers: 0

How to add hyperlink in my DataTables to view the data details and also to update. I already tried but I got an Error When I click the Hyperlink in my table. How to fixed this error? Thanks.

Url.py
path('VM/Details/<int:pk>', vehicleMasterDetails.as_view(), name='vehicle_details'),

**Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/vehicle_details/undefined**

    $(document).ready(function() {
        var table = $('#vtable').DataTable({
            "serverSide": false,
            "scrollX": true,
            "deferRender": true,
            "ajax": {
                "url": "/api/masterlist/?format=datatables",
                "type": "POST"
                },
            "columns": [
                {"data":"id", "name":"id",
                    fnCreatedCell: function (nTd, sData, data, iRow, iCol) {
                        $(nTd).html("<a href='/vehicle_details/"+data.id+"'>"+data.id+"</a>");
                    }
                },
                {"data": "Activity_Id"},
                {"data":"NO"},
                {"data":"PLATE_NO"},
                {"data":"CS_NO"},
                {"data":"CR_NAME"},
            ]
      });
    </script>

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    When you say "update", are you using Editor? If not, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.