sorting desc not working for me SOLVED
sorting desc not working for me SOLVED
James Payne
Posts: 15Questions: 0Answers: 0
Hello,
I am using the server-side processing part of this fabulous piece of software and have it working as needed except for one thing. I cannot for the life of me get the columns to sort in reverse order (desc).
Can anyone see where I am going wrong? I have 5 columns called contacts_id, companyname, clienttype, businesstype and sales_contact. The ordering by asc works fine but if I sort a column by asc then click on it again to sort it by desc the icon changes but not sorting occurs.
I'm using the following code:
[code]
$(document).ready(function() {
$('#example').dataTable({
"bJQueryUI": true,
'bProcessing':true,
"bServerSide":true,
"bSort":true,
"sPaginationType": "full_numbers",
"sAjaxSource": "includes/record_server_processing.php",
});
});
[/code]
and
[code]
<?php
/* MySQL connection */
$gaSql['user'] = "root";
$gaSql['password'] = "jamesp";
$gaSql['db'] = "customer_database";
$gaSql['server'] = "localhost";
$gaSql['type'] = "mysql";
$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'] ) )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
/* Ordering */
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i
[/code]
Thanks,
James
I am using the server-side processing part of this fabulous piece of software and have it working as needed except for one thing. I cannot for the life of me get the columns to sort in reverse order (desc).
Can anyone see where I am going wrong? I have 5 columns called contacts_id, companyname, clienttype, businesstype and sales_contact. The ordering by asc works fine but if I sort a column by asc then click on it again to sort it by desc the icon changes but not sorting occurs.
I'm using the following code:
[code]
$(document).ready(function() {
$('#example').dataTable({
"bJQueryUI": true,
'bProcessing':true,
"bServerSide":true,
"bSort":true,
"sPaginationType": "full_numbers",
"sAjaxSource": "includes/record_server_processing.php",
});
});
[/code]
and
[code]
<?php
/* MySQL connection */
$gaSql['user'] = "root";
$gaSql['password'] = "jamesp";
$gaSql['db'] = "customer_database";
$gaSql['server'] = "localhost";
$gaSql['type'] = "mysql";
$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'] ) )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
/* Ordering */
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i
[/code]
Thanks,
James
This discussion has been closed.
Replies
I wasn't aware of the scripts under the development tab. It might be worth creating a link from the Server-Side Examples page for people like myself! ;-)
Thanks again,
James