Datatable is not displaying on view page
up vote
0
down vote
favorite
I am using CodeIgniter, Datatable is not working. I am displaying all the records in the data table. but it's not displaying. I am getting my view page like this.
I am getting the records from my model. There is no issue with the model. Let me know if require the model code.
Would you help me out on this issue?
view
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<table cellspacing="0" id="team_members_list">
<thead>
<tr>
<th> Employee Name </th>
<th> EMP ID</th>
<th> Mobile No. </th>
<th> Designation </th>
<th> Role </th>
<th> Status </th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
js
$(document).ready(function() {
var oTable = $('#team_members_list').DataTable({
'responsive': true,
//"processing": true,
// "serverSide": true,
"pageLength": 10,
"ajax": {
"url": baseUrl + "/Employee_control/team_members",
"type": "POST"
},
"columns": [{
"data": "name"
},
{
"data": "employee_id"
},
{
"data": "mobileno"
},
{
"data": "emp_designation"
},
{
"data": "emp_role_name"
}
],
'responsive': true
});
});
Controller
public function team_members(){
$draw = intval($this->input->get("draw"));
$start = intval($this->input->get("start"));
$length = intval($this->input->get("length"));
$books = $this->Employee_model->getTotalList_of_TeamLeader();
$data['draw'] = 1;
$data['recordsTotal'] = count($books);
$data['recordsFiltered'] = count($books);
// // $n=1;
foreach ($books as $key => $row)
{
$arr_result = array(
// "Sr.No" => $n,
"id" => base64_encode($this->encryption->encrypt($row->id)),
"name" => $row->firstname.' ' .$row->lastname,
"employee_id" => $row->employee_id,
"mobileno" => $row->mobileno,
"emp_designation" => $row->emp_designation,
"emp_role_name" => $row->emp_role_name,
"emp_teamLeader" => $row->team_leadername
);
$data['data'] = $arr_result;
}
echo json_encode($data);
exit;
}
php ajax html5 datatable codeigniter-3
add a comment |
up vote
0
down vote
favorite
I am using CodeIgniter, Datatable is not working. I am displaying all the records in the data table. but it's not displaying. I am getting my view page like this.
I am getting the records from my model. There is no issue with the model. Let me know if require the model code.
Would you help me out on this issue?
view
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<table cellspacing="0" id="team_members_list">
<thead>
<tr>
<th> Employee Name </th>
<th> EMP ID</th>
<th> Mobile No. </th>
<th> Designation </th>
<th> Role </th>
<th> Status </th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
js
$(document).ready(function() {
var oTable = $('#team_members_list').DataTable({
'responsive': true,
//"processing": true,
// "serverSide": true,
"pageLength": 10,
"ajax": {
"url": baseUrl + "/Employee_control/team_members",
"type": "POST"
},
"columns": [{
"data": "name"
},
{
"data": "employee_id"
},
{
"data": "mobileno"
},
{
"data": "emp_designation"
},
{
"data": "emp_role_name"
}
],
'responsive': true
});
});
Controller
public function team_members(){
$draw = intval($this->input->get("draw"));
$start = intval($this->input->get("start"));
$length = intval($this->input->get("length"));
$books = $this->Employee_model->getTotalList_of_TeamLeader();
$data['draw'] = 1;
$data['recordsTotal'] = count($books);
$data['recordsFiltered'] = count($books);
// // $n=1;
foreach ($books as $key => $row)
{
$arr_result = array(
// "Sr.No" => $n,
"id" => base64_encode($this->encryption->encrypt($row->id)),
"name" => $row->firstname.' ' .$row->lastname,
"employee_id" => $row->employee_id,
"mobileno" => $row->mobileno,
"emp_designation" => $row->emp_designation,
"emp_role_name" => $row->emp_role_name,
"emp_teamLeader" => $row->team_leadername
);
$data['data'] = $arr_result;
}
echo json_encode($data);
exit;
}
php ajax html5 datatable codeigniter-3
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using CodeIgniter, Datatable is not working. I am displaying all the records in the data table. but it's not displaying. I am getting my view page like this.
I am getting the records from my model. There is no issue with the model. Let me know if require the model code.
Would you help me out on this issue?
view
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<table cellspacing="0" id="team_members_list">
<thead>
<tr>
<th> Employee Name </th>
<th> EMP ID</th>
<th> Mobile No. </th>
<th> Designation </th>
<th> Role </th>
<th> Status </th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
js
$(document).ready(function() {
var oTable = $('#team_members_list').DataTable({
'responsive': true,
//"processing": true,
// "serverSide": true,
"pageLength": 10,
"ajax": {
"url": baseUrl + "/Employee_control/team_members",
"type": "POST"
},
"columns": [{
"data": "name"
},
{
"data": "employee_id"
},
{
"data": "mobileno"
},
{
"data": "emp_designation"
},
{
"data": "emp_role_name"
}
],
'responsive': true
});
});
Controller
public function team_members(){
$draw = intval($this->input->get("draw"));
$start = intval($this->input->get("start"));
$length = intval($this->input->get("length"));
$books = $this->Employee_model->getTotalList_of_TeamLeader();
$data['draw'] = 1;
$data['recordsTotal'] = count($books);
$data['recordsFiltered'] = count($books);
// // $n=1;
foreach ($books as $key => $row)
{
$arr_result = array(
// "Sr.No" => $n,
"id" => base64_encode($this->encryption->encrypt($row->id)),
"name" => $row->firstname.' ' .$row->lastname,
"employee_id" => $row->employee_id,
"mobileno" => $row->mobileno,
"emp_designation" => $row->emp_designation,
"emp_role_name" => $row->emp_role_name,
"emp_teamLeader" => $row->team_leadername
);
$data['data'] = $arr_result;
}
echo json_encode($data);
exit;
}
php ajax html5 datatable codeigniter-3
I am using CodeIgniter, Datatable is not working. I am displaying all the records in the data table. but it's not displaying. I am getting my view page like this.
I am getting the records from my model. There is no issue with the model. Let me know if require the model code.
Would you help me out on this issue?
view
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<table cellspacing="0" id="team_members_list">
<thead>
<tr>
<th> Employee Name </th>
<th> EMP ID</th>
<th> Mobile No. </th>
<th> Designation </th>
<th> Role </th>
<th> Status </th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
js
$(document).ready(function() {
var oTable = $('#team_members_list').DataTable({
'responsive': true,
//"processing": true,
// "serverSide": true,
"pageLength": 10,
"ajax": {
"url": baseUrl + "/Employee_control/team_members",
"type": "POST"
},
"columns": [{
"data": "name"
},
{
"data": "employee_id"
},
{
"data": "mobileno"
},
{
"data": "emp_designation"
},
{
"data": "emp_role_name"
}
],
'responsive': true
});
});
Controller
public function team_members(){
$draw = intval($this->input->get("draw"));
$start = intval($this->input->get("start"));
$length = intval($this->input->get("length"));
$books = $this->Employee_model->getTotalList_of_TeamLeader();
$data['draw'] = 1;
$data['recordsTotal'] = count($books);
$data['recordsFiltered'] = count($books);
// // $n=1;
foreach ($books as $key => $row)
{
$arr_result = array(
// "Sr.No" => $n,
"id" => base64_encode($this->encryption->encrypt($row->id)),
"name" => $row->firstname.' ' .$row->lastname,
"employee_id" => $row->employee_id,
"mobileno" => $row->mobileno,
"emp_designation" => $row->emp_designation,
"emp_role_name" => $row->emp_role_name,
"emp_teamLeader" => $row->team_leadername
);
$data['data'] = $arr_result;
}
echo json_encode($data);
exit;
}
php ajax html5 datatable codeigniter-3
php ajax html5 datatable codeigniter-3
asked Nov 11 at 6:47
user9437856
362111
362111
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
You are continually overwriting the same variable in your controller to build up the data, so change it to use to add the data...
$arr_result = ; // Initialise the array
foreach ($books as $key => $row)
{
$arr_result = array(
// "Sr.No" => $n,
"id" => base64_encode($this->encryption->encrypt($row->id)),
"name" => $row->firstname.' ' .$row->lastname,
"employee_id" => $row->employee_id,
"mobileno" => $row->mobileno,
"emp_designation" => $row->emp_designation,
"emp_role_name" => $row->emp_role_name,
"emp_teamLeader" => $row->team_leadername
);
}
// Add to main data after loop has finished
$data['data'] = $arr_result;
Thanks for the answer,I updated your code with my code. Now i am getting 37 records but still my view not displaying. I mean records are not displaying like list in datatable
– user9437856
Nov 11 at 7:08
Oh! wait I think there is some issue from my end. give me some time to check.
– user9437856
Nov 11 at 7:19
Have you checked your console? Normally you can check returning data in Browser->Network tab , if some errors caused on front-end you can see them on console tab as well
– Rega
Nov 11 at 8:48
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
You are continually overwriting the same variable in your controller to build up the data, so change it to use to add the data...
$arr_result = ; // Initialise the array
foreach ($books as $key => $row)
{
$arr_result = array(
// "Sr.No" => $n,
"id" => base64_encode($this->encryption->encrypt($row->id)),
"name" => $row->firstname.' ' .$row->lastname,
"employee_id" => $row->employee_id,
"mobileno" => $row->mobileno,
"emp_designation" => $row->emp_designation,
"emp_role_name" => $row->emp_role_name,
"emp_teamLeader" => $row->team_leadername
);
}
// Add to main data after loop has finished
$data['data'] = $arr_result;
Thanks for the answer,I updated your code with my code. Now i am getting 37 records but still my view not displaying. I mean records are not displaying like list in datatable
– user9437856
Nov 11 at 7:08
Oh! wait I think there is some issue from my end. give me some time to check.
– user9437856
Nov 11 at 7:19
Have you checked your console? Normally you can check returning data in Browser->Network tab , if some errors caused on front-end you can see them on console tab as well
– Rega
Nov 11 at 8:48
add a comment |
up vote
0
down vote
accepted
You are continually overwriting the same variable in your controller to build up the data, so change it to use to add the data...
$arr_result = ; // Initialise the array
foreach ($books as $key => $row)
{
$arr_result = array(
// "Sr.No" => $n,
"id" => base64_encode($this->encryption->encrypt($row->id)),
"name" => $row->firstname.' ' .$row->lastname,
"employee_id" => $row->employee_id,
"mobileno" => $row->mobileno,
"emp_designation" => $row->emp_designation,
"emp_role_name" => $row->emp_role_name,
"emp_teamLeader" => $row->team_leadername
);
}
// Add to main data after loop has finished
$data['data'] = $arr_result;
Thanks for the answer,I updated your code with my code. Now i am getting 37 records but still my view not displaying. I mean records are not displaying like list in datatable
– user9437856
Nov 11 at 7:08
Oh! wait I think there is some issue from my end. give me some time to check.
– user9437856
Nov 11 at 7:19
Have you checked your console? Normally you can check returning data in Browser->Network tab , if some errors caused on front-end you can see them on console tab as well
– Rega
Nov 11 at 8:48
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
You are continually overwriting the same variable in your controller to build up the data, so change it to use to add the data...
$arr_result = ; // Initialise the array
foreach ($books as $key => $row)
{
$arr_result = array(
// "Sr.No" => $n,
"id" => base64_encode($this->encryption->encrypt($row->id)),
"name" => $row->firstname.' ' .$row->lastname,
"employee_id" => $row->employee_id,
"mobileno" => $row->mobileno,
"emp_designation" => $row->emp_designation,
"emp_role_name" => $row->emp_role_name,
"emp_teamLeader" => $row->team_leadername
);
}
// Add to main data after loop has finished
$data['data'] = $arr_result;
You are continually overwriting the same variable in your controller to build up the data, so change it to use to add the data...
$arr_result = ; // Initialise the array
foreach ($books as $key => $row)
{
$arr_result = array(
// "Sr.No" => $n,
"id" => base64_encode($this->encryption->encrypt($row->id)),
"name" => $row->firstname.' ' .$row->lastname,
"employee_id" => $row->employee_id,
"mobileno" => $row->mobileno,
"emp_designation" => $row->emp_designation,
"emp_role_name" => $row->emp_role_name,
"emp_teamLeader" => $row->team_leadername
);
}
// Add to main data after loop has finished
$data['data'] = $arr_result;
answered Nov 11 at 7:02
Nigel Ren
23k61832
23k61832
Thanks for the answer,I updated your code with my code. Now i am getting 37 records but still my view not displaying. I mean records are not displaying like list in datatable
– user9437856
Nov 11 at 7:08
Oh! wait I think there is some issue from my end. give me some time to check.
– user9437856
Nov 11 at 7:19
Have you checked your console? Normally you can check returning data in Browser->Network tab , if some errors caused on front-end you can see them on console tab as well
– Rega
Nov 11 at 8:48
add a comment |
Thanks for the answer,I updated your code with my code. Now i am getting 37 records but still my view not displaying. I mean records are not displaying like list in datatable
– user9437856
Nov 11 at 7:08
Oh! wait I think there is some issue from my end. give me some time to check.
– user9437856
Nov 11 at 7:19
Have you checked your console? Normally you can check returning data in Browser->Network tab , if some errors caused on front-end you can see them on console tab as well
– Rega
Nov 11 at 8:48
Thanks for the answer,I updated your code with my code. Now i am getting 37 records but still my view not displaying. I mean records are not displaying like list in datatable
– user9437856
Nov 11 at 7:08
Thanks for the answer,I updated your code with my code. Now i am getting 37 records but still my view not displaying. I mean records are not displaying like list in datatable
– user9437856
Nov 11 at 7:08
Oh! wait I think there is some issue from my end. give me some time to check.
– user9437856
Nov 11 at 7:19
Oh! wait I think there is some issue from my end. give me some time to check.
– user9437856
Nov 11 at 7:19
Have you checked your console? Normally you can check returning data in Browser->Network tab , if some errors caused on front-end you can see them on console tab as well
– Rega
Nov 11 at 8:48
Have you checked your console? Normally you can check returning data in Browser->Network tab , if some errors caused on front-end you can see them on console tab as well
– Rega
Nov 11 at 8:48
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246477%2fdatatable-is-not-displaying-on-view-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown