Telephone field to make calls

Telephone field to make calls

jalapejalape Posts: 117Questions: 2Answers: 1

Good Morning,
I am trying to create a link so that I can make calls from a phone field in a table.
I'm using an html <a> tag in the columns: data, but it doesn't show me the field data.

{
   "render": function (data, type, JsonResultRow, meta) {
      return '<a href="tel:'+JsonResultRow.tb_contacto.telefonoFijo+'"></a>';
   }
},

Thank you

Replies

  • kthorngrenkthorngren Posts: 20,276Questions: 26Answers: 4,765

    There is not an obvious issue with the code snippet you posted. Do you get errors in the browser's console?

    Please post a link to your page or a test case replicating the issue so we an see exactly what you have and offer suggestions.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • jalapejalape Posts: 117Questions: 2Answers: 1
    I've found a way to do it,
    
            { 
                    data: "tb_contacto.telefonoFijo",
                    "render": function(data, type, row, meta){
                        if(type === 'display'){
                            data = '<a href="tel:' + data + '">' + data + '</a>';
                        }
                        return data;
                    }
                },
    

    Thank you

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    Thanks for posting back. Good to hear you’ve got it working.

    Allan

This discussion has been closed.