最初のアイデアに従って、詳細ポップアップを使用すると、コントローラーは次のようになります。
public function Listdetails_ajax(){
$draw = intval($this->input->get("draw"));
$start = intval($this->input->get("start"));
$length = intval($this->input->get("length"));
$books = $this->Search_model->getTotalList_of_primary();
$data['draw'] = 1;
$data['recordsTotal'] = count($books);
$data['recordsFiltered'] = count($books);
foreach ($books as $key => $row)
{
//print_r($row->customer_id);
$arr_result = array(
"member_id" => base64_encode($this->encryption->encrypt($row->member_id)),
"profile_pic" => $row->profile_pic,
"name" => $row->first_name.' ' .$row->last_name,
"phone" => $row->phone,
"chss_no" => $row->chss_no,
"emp_id" => $row->emp_id,
"address" => $row->address
// "member_type" => $row->member_type
);
$array_secondary = array();
$books_of_secondary = $this->Search_model->getTotalList_of_secondary($row->customer_id);
foreach ($books_of_secondary as $key => $row)
{
//print_r($row->customer_id);
$arr_result2 = array(
"s_member_id" => base64_encode($this->encryption->encrypt($row->member_id)),
"s_profile_pic" => $row->profile_pic,
"s_name" => $row->first_name.' ' .$row->last_name,
"s_phone" => $row->phone,
"s_chss_no" => $row->chss_no,
"s_emp_id" => $row->emp_id,
"s_address" => $row->address
);
$array_secondary[] = $arr_result2;
}
$arr_result['secondary'] = $array_secondary;
$data['data'][] = $arr_result;
}
echo json_encode($data);
exit;
}
次に、フォーマット関数でsecondary
にアクセスします セカンダリの配列を取得するフィールド。多分このように:
function format(d) {
// d is the original data object for the row var val;
if(d.secondary.length == 0) {
return "There are no secondary members";
}
var display = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">';
for (val of d.secondary) {
display += '<tr>' + '<td>Full name:</td>' + '<td>' + val.s_name + '</td>' + '</tr>' + '<tr>' + '<td>Mobile number:</td>' + '<td>' + val.s_phone + '</td>' + '</tr>';
}
display += '</table>';
return display;
}