Post Method onClick with Popup

Post Method onClick with Popup

klay20klay20 Posts: 4Questions: 1Answers: 0

Hi everyone,

Im getting my data from api, and i want when i click a button on my table a popup will open and i will send several data to my db.

How can i achieve that? Is there any solution or example about post method with popup on datatable?

Answers

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    Forms and posting back wouldn't be provided by DataTables, but you could create a custom button using the Buttons extension that triggers that code.

    Colin

  • klay20klay20 Posts: 4Questions: 1Answers: 0

    Thanks, i've already these;

    $('#myTable').DataTable( {
    buttons: [
    'open', 'excel', 'pdf'
    ]
    } );

    But how can i access to "open" button for manipulate with functions?

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    You would use the action function - see example here. There it's just creating an alert, but you could have your form instead.

    Colin

  • klay20klay20 Posts: 4Questions: 1Answers: 0
    edited June 2021

    I need a button for open popup in every single row at table. Is that possible with datatable? Or should i use javascript?

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794

    This example shows how to create a click event handler for the rows. The example shows how to get the row data. Creating an edit form that can be submitted via ajax is not built into Datatables. You will need to write this code or you can purchase the Editor which has this functionality.

    Kevin

  • klay20klay20 Posts: 4Questions: 1Answers: 0
    edited June 2021

    I added to document.ready function on index

     var table = $('#example').DataTable();
    $('#example tbody').on('click', 'tr', function () {
        var data = table.row( this ).data();
        alert( 'You clicked on '+data[0]+'\'s row' );
    

    The incoming data value from api in react js, it doesnt work.

    Is that problem rendering data on datatables with this function?

    Should i add this code in rendering js part or another?

Sign In or Register to comment.