Own unique url for each entry

Own unique url for each entry

PetrrezenPetrrezen Posts: 2Questions: 0Answers: 0

Help, I don't understand JS
in the demo table. Links work only on the first letters of the Position.
https://datatables.net/examples/basic_init/data_rendering.html
I want all links to be in JS. And to work for a unique job title, and not for a capital letter like on a demo

                    if (data[0] < '???') {
                        link = "http://cloudtables.com";
                    }
                    else if (data[0] < 'Support Engineer') {
                        link = "http://editor.datatables.net";
                    }

                    return '<a href="' + link + '">' + data + '</a>';
                }

                return data;
            }
        },   ```

Replies

  • rf1234rf1234 Posts: 2,950Questions: 87Answers: 416

    That's just an arbitrary example. You can code this anyway you like!

    {
        data: 'position',
        render: function(data, type) {
        if (type === 'display') {
           let link = "http://datatables.net";
           if (data == 'Accountant') {
                link = "http://cloudtables.com";
            } else if (data == 'Sales Assistant') {
                link = "http://editor.datatables.net";
            }
            return '<a href="' + link + '">' + data + '</a>';
         }
         return data;
       }
     },
    
  • PetrrezenPetrrezen Posts: 2Questions: 0Answers: 0

    Thank you very much for your help. Tables form table tennis ranking

  • rf1234rf1234 Posts: 2,950Questions: 87Answers: 416

    You are welcome! I understand your problem though: Many of the examples are overly simplistic and have not much in common with real world situations. That can be confusing at times. So always bear in mind: It's just examples not templates :smile:

    Apart from this I don't think you'll find many free solutions that have such a rich documentation, and such an active and supportive forum as Data Tables. A big thank you to @allan and his team for that.

    Roland

  • allanallan Posts: 63,237Questions: 1Answers: 10,418 Site admin

    Thanks Roland! It is people such as yourself and Kevin that make it such a pleasure to work in and with the open source community.

    Allan

Sign In or Register to comment.