Datatables Search is not working on first column with SSP Class
Datatables Search is not working on first column with SSP Class
SalmanS
Posts: 102Questions: 12Answers: 0
My problem is the search is not working on my first column if its a single digit number i.e,
serial number 1 to 9 but the rest of the columns the datatables search is working fine.
or maybe my code needs little tweaks.
Here is the code
`
<script>
// global the manage memeber table
var manageMemberTable;
$(document).ready(function() {
manageMemberTable = $("#manageMemberTable").DataTable({
"aLengthMenu": [
[5, 10, 15, -1],
[5, 10, 15, "All"]
],
"processing": true,
"serverSide": true,
"type": "POST",
"datatype": "json",
"dataSrc": "",
"ajax": {
"url": "server_inprocess.php",
},
"columns": [
{ "data": "0", "name": "0", "autoWidth": true },
{ "data": "1", "name": "1", "autoWidth": true },
{ "data": "2", "name": "2", "autoWidth": true },
{ "data": "3", "name": "3", "autoWidth": true },
{
"targets": -1,
"orderable": false,
"data": "null",
"className": "center",
"defaultContent": '<a type="button" class="edit btn btn-primary"> <span class="glyphicon glyphicon-edit"></span>  Edit</a> / <a type="button" class="delete btn btn-primary" > <span class="glyphicon glyphicon-trash"></span>  Delete</a>'
}
]
});
});
</script>
`
Here is my ssp class code,
`
<?php
/*
* DataTables example server-side processing script.
*
* Please note that this script is intentionally extremely simply to show how
* server-side processing can be implemented, and probably shouldn't be used as
* the basis for a large complex system. It is suitable for simple use cases as
* for learning.
*
* See http://datatables.net/usage/server-side for full details on the server-
* side processing requirements of DataTables.
*
* @license MIT - http://datatables.net/license_mit
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
// DB table to use
$table = 'tblcomplaints';
// Table's primary key
$primaryKey = 'complaintnumber';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 'complaintnumber', 'dt' => 0 ),
array( 'db' => 'regDate','dt' => 1,
'formatter' => function( $d, $row ) {
return date( 'd-m-Y', strtotime($d));
}),
array( 'db' => 'lastUpdationDate', 'dt' => 2 ),
array( 'db' => 'status', 'dt' => 3 )
);
// SQL server connection information
$sql_details = array(
'user' => 'root',
'pass' => '',
'db' => 'testing',
'host' => ''
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP
* server-side, there is no need to edit below this line.
*/
require( 'vendor\ssp.class.php' );
//$where = "status ='in process'";
echo json_encode(
// SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns, $where )
SSP::complex( $_GET, $sql_details, $table, $primaryKey, $columns, null, "status is null" )
);
`
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
as you can see my first column is defined in array and its the complaintnumber primary key, column[0]..
Hi @SalmanS ,
When you say it doesn't work, do you mean it doesn't filter out? I suspect the issue is that it is working, but other rows also match. For example, if you search for "1", the odds are, the date field will contain a "1" in it.
Cheers,
Colin
You are right but I have a record no. 4 with complaint number 4 which it does not filter?
As no. 4 is not used in any part of the data except just one record.
Wish I have a fiddle to prove?
I noticed maybe a mistake in my script where i used "data": "1", "name": "1"? do i have to change the "name" to the actual column name here... Will this have any adverse effect?
Hi @SalmanS ,
No, the name can be anything, it's just used as a reference. But yep, a fiddle would be a good way to go here.
Cheers,
Colin
unfortunatley there is not i am aware where i can use fiddle for using ssp class.? do you have any sample fiddle with SSP Class to test?
Apologies for the inconvenience?
Anyone...
I think the best thing here is if you could either create that fiddle or link to your page. All the examples on this page are using SSP, so they can act as examples. I suspect there's hidden characters in HTML in your cells that are causing, so a link would be the most useful,
Cheers,
Colin