Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82435

how i can change html of td and tr after i get data by json

$
0
0

hello

first of all this is my codes

HTML:

<table id="table_mydrug" class="table table-bordered table-striped sticky-header">
                <thead>
                <tr>
                  <th>Name</th>
                  <th>Scientific</th>
                  <th>Concentration</th>
                  <th>DosageForm</th>
                  <th>More Info</th>
                  <th>Sachet</th>
                  <th>Location</th>
                  <th>Quantity</th>
                  <th>Action</th>
                </tr>
                </thead>

              </table>

PHP:

$query="SELECT * FROM items  WHERE  slocation !=''";
$result=mysqli_query($db_conn, $query);


while($row = $result->fetch_array(MYSQLI_ASSOC)){

  $data[] = $row;

}


$results = ["sEcho" => 1,

          "iTotalRecords" => count($data),

          "iTotalDisplayRecords" => count($data),

          "aaData" => $data ];


echo json_encode($results);

Javascript:

        $(function () {
            $('#table_mydrug').DataTable({
                "bProcessing": true,
              "sAjaxSource": "test2.php",
               "aoColumns": [

                      { mData: 'name' } ,

                      { mData: 'scientific' },

                      { mData: 'concentration' },

                      { mData: 'dosageform' },

                      { mData: 'store' },

                      { mData: 'sachet' },

                      { mData: 'slocation' },

                      { mData: 'squantity' },

                      { mData: 'id' },

                    ],
              'paging'      : true,
              'lengthChange': false,
              'searching'   : true,
              'order'    : [],
              'info'        : true,
              'autoWidth'   : false,
            'bSortable' : false,
            'aTargets'  : [ 1 ],
            'lengthMenu': [100],
            })
          })

all its work 100%

my question is the html code dont have this tags:

<tbody>
<tr>
<td></td>
</tr>
</tbody>

so how i can edit html for this please ! because i need to edit the design of results after i get json data to my table!

hope you understand me!


Viewing all articles
Browse latest Browse all 82435

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>