Custom Buttom to external link with GET data

Custom Buttom to external link with GET data

fedefazzfedefazz Posts: 19Questions: 6Answers: 1

Hi i have the editor and i want to perform a custom button with GET data to a external link. The GET data must be de ID of the ROW. Here is the link of the web page with the button displayed http://www.eliseoweb.com.ar/test/. I don't know how to add a the ID data to the button. Heres my code, i get this code from other post of the forum.
{"sExtends": "text",
"sButtonText": 'Custom Buttom',
"fnClick": function ( nButton, oConfig, oFlash ) {
window.open('http://www.midominio.com.ar?id=$ID', '_blank');
console.log('nButton: ', nButton);
console.log('oConfig: ', oConfig);
console.log('oFlash: ', oFlash);
},
"fnInit": function ( nButton, oConfig ) {
$(nButton).addClass('btn btn-primary m-r-5 m-b-5');
}}

The button must be disable (Like update or Remove) until the user select a row. The objetive of this button is to provide the user a template of the row for printing in a envelope.

Thanks
Federico

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Hi,

    It sounds like you want to use the select_single button type. Just add an fnClick action to make the Ajax request you need.

    You can get the data for the selected row use the fnGetSelectedData TableTools API method. This is what the Editor buttons are doing as well!

    Allan

  • fedefazzfedefazz Posts: 19Questions: 6Answers: 1
    edited August 2015

    Solved this way

    sExtends: "select_single",
    sButtonText: "Imprimir Sobre",
    "fnClick": function (nButton, oConfig) {
                var sData = this.fnGetSelectedData(oConfig);
                 var rowId = sData[0].id
             window.open('http://www.eliseoweb.com.ar/test/sobre.php?codigo='+rowId, '_blank');
                return false;
    

    Thanks Allan

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Nice one - thanks for showing us your code.

    Allan

This discussion has been closed.