daily pastebin goal
78%
SHARE
TWEET

Untitled

a guest Jan 18th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ---//JS get_value input type hidden from control c_message
  2. $("#table-message").on('change',"input[type='checkbox']",function(e){
  3.         var checked_comment = $('input[name=cek_data]:checked').map(function(){
  4.                    return $(this).prevAll('input').prev().val(); //ambil nilai dr sebelum checkbox cek_data/name="cek_commentFile"
  5.                 }).get();
  6.         alert(checked_comment);
  7. })
  8.  
  9. ---//controller c_message
  10. function ajax_datatables($flag) {
  11.         $get = $this->m_message->get_data($flag);
  12.         $data = array();
  13.         $count_filtered = $this->m_message->count_filtered($flag);
  14.         foreach ($get as $value) {
  15.             $row = array();
  16.             $row[] = '<input type="hidden" name="cek_file" value="'.$this->m_message->get_file_name($value->id_message).'">
  17.             <input type="hidden" name="cek_commentFile" value="'.$this->m_message->get_comment_file($value->id_message).'"> // parsing value id_message to model
  18.             <input type="hidden" name="cek_comment" value="'.$this->m_message->get_comment_message($value->id_message).'">
  19.             <input type="checkbox" id="checked" name="cek_data" value="'.$value->id_message.'">';
  20.             $row[] = $value->subject;
  21.             $row[] = $value->surname;
  22.             $row[] = $value->message_to;
  23.             $row[] = $this->m_message->count_comment($value->id_message)+1;
  24.             $row[] = $this->m_message->last_reply($value->id_message);
  25.             $row[] = '<a class="btn btn-info " href="javascript:void(0)" onclick="view_message_assist('."'".$value->id_message."','message'".')" data-toggle="tooltip" title="View Message"><i class="fa fa-comments fa-lg"></i></a>';
  26.             $data[] = $row;
  27.         }
  28.         $output = array(
  29.             "draw" => $_POST['draw'],
  30.             "recordsTotal" => $this->m_message->count_all(),
  31.             "recordsFiltered" => $count_filtered,
  32.             "data" => $data,
  33.         );
  34.         echo json_encode($output);
  35.     }
  36.  
  37. ---//model m_message
  38. function get_comment_file($id){ //get_param from $value->id_message
  39.         // $arr = array('41','42');  
  40.     $this->db->where_in('id_content',$id) // error, $id harus dijadikan array karena ambil $id dari multiple id_message(41,42,42)
  41.             ->where('content','message')
  42.             ->where('type','file');
  43.     $query = $this->db->get('comment');
  44.     foreach ($query->result_array() as $row){
  45.         $res[] = $row['comment']; //output dijadikan array $res[]
  46.     }
  47.     $row_comment = implode(",", $res); //set sparator comma
  48.     return $row_comment; //1.jpg,2.jpg...
  49.     }
  50.  
  51. **PERTANYAANYA**
  52. -- 1. gimana ambil data $row['comment']; dari nilai multiple id_message?
  53. misal table design:
  54. |id_message || comment
  55. |41         || 1.jpg,2.jpg
  56. |42         || 3.jpg
  57. jadi nanti outputnya, 1.jpg,2.jpg,3.jpg
  58.  
  59. **PROSESNYA**
  60. 1. waktu checkbox diclik, lalu di controler dia parse id_message ke model get_comment_file! value id_message itu kehidden lihat javascript
  61. 2. nah waktu di model untuk nampilikan result comment, gmna tuh caranya karena id_messagenya kan lebih dr dua wktu ngewhere querynya
  62.  
  63. #thanks mas donyy
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top