我的数据表有一个奇怪的问题。在我的代码中,我有一个jquery onChange代码片段,用于刷新由单独的PHP文件生成的数据表。 jQuery代码如下
anotherArray = this.listCareUnits;
filterListCareUnit(val) {
console.log(val);
this.listCareUnits = this.anotherArray.filter((unit) => unit.label.indexOf(val) > -1);
}
在PHP文件中,我首先构建表
$("select[name='stocktake_id_sel'").on('change', function() {
var stocktake_id = document.getElementsByName("stocktake_id_sel")[0].value;
//alert(stocktake_id);
table.destroy();
$('#tbl_products_list').load('load_purchases.php?action=reload_table&stocktake_id='+stocktake_id+'');
});
然后在同一个PHP文件
中通过jQuery初始化它<table style=' height:10px; margin-left:-10px' id="tbl_products_list" class="table table-fixed table-striped table-bordered datalist" cellspacing="0">
<thead>
<tr >
<th style='width:40%;'> Supplier Name </th>
<th style='width:20%;'> Delivery Number </th>
<th style='width:10%;'> PO Number </th>
<th style='width:10%;'> Delivery Date </th>
<th style='width:10%;'> Cost Value </th>
<th style='width:5%;'> Edit </th>
<th style='width:5%;'> Delete </th>
</tr>
</thead>
<tbody>
<?
$query = "SELECT p.id AS id, p.date AS delivery_date, p.delivery_number, p.po_number, p.cost_value, sp.supplier_name FROM store_purchases p INNER JOIN supplier_master sp ON sp.id = p.supplier_id WHERE p.store_id = '$store_id' AND sp.store_id = '$store_id' AND p.stocktake_id = '$stocktake_id' ;";
//echo $query;
$retval = f_select_query($query, $datarows);
if ($retval == -1 )
{
$connected = false;
return -1;
}
$department_id_dropdown = f_get_dropdown("id", "supplier_name", "supplier_master", "", "supplier_id", " store_id = $store_id", '', '', '', false, false, true);
$rowcount = count($datarows);
for ($counter = 0; $counter< $rowcount; $counter++)
{
$delivery_id = $datarows[$counter]->id;
$supplier_name = truncate(f_htmlspecialchars_decode($datarows[$counter]->supplier_name , ENT_QUOTES), 150);
$delivery_number = $datarows[$counter]->delivery_number;
$po_number = $datarows[$counter]->po_number;
$delivery_date = $datarows[$counter]->delivery_date;
$cost_value = $datarows[$counter]->cost_value;
$kid_value = string_encrypt($datarows[$counter]->id);
if ($po_number == '0')
$po_number = '';
$delivery_date = strtotime($delivery_date);
$delivery_date = date('d-m-Y',$delivery_date);
echo "<tr>";
echo "<td style='width:40%;'>$supplier_name</td>";
echo "<td style='width:20%;'><center> $delivery_number </td>";
echo "<td style='width:10%;'><center>$po_number <input name='product_id' class='form-control product_id' value='$delivery_id' type='hidden'/> </td>";
echo "<td style='width:10%;'><center> $delivery_date </td>";
echo "<td style='width:10%;'><center> $cost_value </td>";
echo "<td style='width:5%;'><button id='products_button' class='btn dt_buttons ajax_forms' data-keyid='' data-source='get_purchase_data.php' data-id='$delivery_id' data-target='popup' data-element=''><i class='fa fa-list fa-md'></i><span> Edit </span></button></td>" ;
echo "<td style='width:5%;'> <span class='delete_record' id='StorePurchases_$kid_value'> <i class='fa fa-trash-o fa-lg'></i> </span></td>";
echo "</tr>";
}
?>
表的第一个实例加载完全没有问题,可以看出here,所有大小都是正确的。但是,每当我对下拉列表进行更改并刷新页面时,即。数据再生,似乎创造了一个奇怪的结果。请看这screenshot 我哪里出错或者我错过了什么?