我有一个使用Datatables动态创建的表。
foreach ($results as $value)
{
echo '
<tr>
<td>'.$value->object_name.'</td>
<td>'.$value->issn.'</td>
<td>'.$value->object_publisher_name.'</td>
<td>'.$value->remarks.'</td>
<td id="chkbutton">'.$form->checkBox($model,"journal_id").'</td>
<td style="display:none;">'.$value->object_id.'</td>
</tr>';
}
当选中相应的复选框时,我必须从隐藏列中获取值(journal_id),然后调用DB以获取具有相应ID的数据并填写下拉列表。我该怎么做?
答案 0 :(得分:0)
foreach ($results as $value)
{
echo '
<tr>
<td>'.$value->object_name.'</td>
<td>'.$value->issn.'</td>
<td>'.$value->object_publisher_name.'</td>
<td>'.$value->remarks.'</td>
<td id="chkbutton">'.$form->checkBox($model,"journal_id").'</td>
<td style="display:none;">'.$value->object_id.'</td>
</tr>';
}
答案 1 :(得分:0)
您需要使用Javascript来指定列的详细信息
var table = $('#journal_table').DataTable({
'columnDefs': [
// These columns not visible. O is first col, 1 is second,
{ 'visible': false, 'targets': [ 5 ] },...
{ ...other settings...}
]
});