This topic contains 1 reply, has 2 voices, and was last updated by Jai Jai 4 months, 1 week ago.

dynamic tr in a datatable


  • softaula
    Participant

    Posts: 25
    Member Reply #15596

    I have a html datatable :

    <table class=”m-datatable” id=”tablaListadoCampanyas”>
    <thead>
    <tr>
    <th title=”Field #1″>
    ID
    </th>
    <th title=”Field #5″>
    Título
    </th>
    <th title=”Field #2″>
    Inicio
    </th>
    <th title=”Field #3″>
    Fin
    </th>
    <th title=”Field #4″>
    Grupo
    </th>
    <th title=”Field #4″>
    Acciones
    </th>
    </tr>
    </thead>
    <tbody>

    <tr>
    <td>
    <?=$idCampanya?>
    </td>
    <td>
    <?=$campanya->getTitulo();?>
    </td>

    I have the code of the trs in a separate file and I call it by php

    Now, I’m working with javascript to replace a tr calling this tr file

    I retreive the data correctly but the tr is not formatted well the same way the initialized trs ara already formatted.

    I tried it but it doesn´t work:

    $.ajax({
    data : {
    idCampanya  : idCampanya,
    des            : des
    },
    url : getEntorno() + ‘/php/restringirCampanya.php’,
    type : ‘post’,
    dataType : “json”,
    success : function(response) {
    if (response[‘ok’] == “1”) {
    a.closest(‘tr’).replaceWith(‘html from the php file where I have the trs’);

    myDatatables.Init(); // it doesn´t format correctly my new tr

     

    How can I do it?

    Thanks!

    Jai
    Jai
    Keymaster

    Posts: 2459
    Support Staff Reply #15680

    Hi 🙂

    Can I know what is the result you get from API /php/restringirCampanya.php?

    Thanks

You must be logged in to reply to this topic.