bSearchable = false not working at all
bSearchable = false not working at all
aswebtechnology
Posts: 19Questions: 0Answers: 0
Hi,
I have applied "bSearchable": false on my columns in datatable but its not working at all. I am using latest version of datatables.
Here is my code
[code]
$(document).ready(function() {
var oTable = $('#view').dataTable( {
"aoColumnDefs": [
{
"fnRender": function (o) {
return ' ';
},
"aTargets": [4],
}
],
// sClass is used to pass css classes to columns
"aoColumns": [
{ "sWidth": "30px" },
{ },
{ "sClass": "aligncenter no_mobile", "sWidth": "50px" },
{ "bSearchable": false, "sClass": "no_mobile", "sWidth": "120px" },
{ "bSearchable": false, "bSortable": false, "sClass": "alignright", "sDefaultContent": "", "sWidth": "30px" }
],
"aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
"bAutoWidth": false,
"bProcessing": true,
"bServerSide": true,
"iDisplayLength": 20,
"sAjaxSource": "pages_view_source.php",
"sPaginationType": "full_numbers"
} );
} );
[/code]
[code]
Id
Title
Views
Date Created
Actions
[/code]
Please help me with it, I need to disable sorting on two columns.
FYI one columns is that of views (int field in mysql) and 2nd one is datecreated (datetime field in mysql).
I have applied "bSearchable": false on my columns in datatable but its not working at all. I am using latest version of datatables.
Here is my code
[code]
$(document).ready(function() {
var oTable = $('#view').dataTable( {
"aoColumnDefs": [
{
"fnRender": function (o) {
return ' ';
},
"aTargets": [4],
}
],
// sClass is used to pass css classes to columns
"aoColumns": [
{ "sWidth": "30px" },
{ },
{ "sClass": "aligncenter no_mobile", "sWidth": "50px" },
{ "bSearchable": false, "sClass": "no_mobile", "sWidth": "120px" },
{ "bSearchable": false, "bSortable": false, "sClass": "alignright", "sDefaultContent": "", "sWidth": "30px" }
],
"aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
"bAutoWidth": false,
"bProcessing": true,
"bServerSide": true,
"iDisplayLength": 20,
"sAjaxSource": "pages_view_source.php",
"sPaginationType": "full_numbers"
} );
} );
[/code]
[code]
Id
Title
Views
Date Created
Actions
[/code]
Please help me with it, I need to disable sorting on two columns.
FYI one columns is that of views (int field in mysql) and 2nd one is datecreated (datetime field in mysql).
This discussion has been closed.
Replies
[code]
<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Set variables
*/
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array( 'page_id','title', 'views', 'datecreated');
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "page_id";
/* DB table to use */
$sTable = TABLE_PAGES;
/* Database connection information */
$gaSql['user'] = DB_USER;
$gaSql['password'] = DB_PASS;
$gaSql['db'] = DB_NAME;
$gaSql['server'] = DB_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
*/
/*
* MySQL connection
*/
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );
/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i
[/code]
[code]
if ( isset($_GET['bSearchable_'.$i]) && $_GET['bSearchable_'.$i] == "true" )
{
$sWhere .= $aColumns[$i]." LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ";
}
[/code]
http://datatables.net/development/server-side/php_mysql