How to set same hyperlink for multiple columns?

How to set same hyperlink for multiple columns?

termistermis Posts: 5Questions: 2Answers: 1

I have 2 columns that I want to be linkable, I want link to be related to the data of first column. Here's my code:

        $(document).ready(function() {
        var json=JSON.stringify({{ suppliers_all | safe }});
            $('#mydata').DataTable( {
                  "data": JSON.parse(json),
                    "columns": [
                        { "data": "number" },
                        { "data": "name" },
                        { "data": "classification" },
                        { "data": "location" },
                        { "data": "product_family" },
                        { "data": "category" },
                        { "data": "competence" },
                        { "data": "updated" }
                    ],
                      "columnDefs": [ { //link clickable
                        "targets": [0, 1],
                        "data": "number",
                        "render": function ( data, type, full, meta ) {
                          return '<a href="'+data+'">'+data+'</a>';
                        }
                      } ]
            } );

        } );

Problem is with the return '<a href="'+data+'">'+data+'</a>'; which returns NAME instead of NUMBER for the second column. How do I use the first column data for both columns when generating a link?

Answers

  • termistermis Posts: 5Questions: 2Answers: 1
    edited January 2017

    Solved by using property of full.number instead of data.

This discussion has been closed.