So its come to this.....

So its come to this.....

llhhyyllhhyy Posts: 4Questions: 0Answers: 0
edited December 2012 in General
I am making a website about a shuffleboard league. And for the past 3 weeks I have tried to get my tables to look like the sample on this page, http://datatables.net/release-datatables/extras/FixedColumns/two_columns.html The only thing I want to change about this table is to sort by descending order on first click. However I have failed miserably. So at this point I am asking, does anyone have a working table like this one with code they are willing to share?

Replies

  • allanallan Posts: 63,683Questions: 1Answers: 10,498 Site admin
    Use asSorting to change the order of how the sorting is applied.

    Allan
  • llhhyyllhhyy Posts: 4Questions: 0Answers: 0
    Awesome I got the descending order to work!

    Now I would like to get the first 2 columns fixed. I am using iLeftColumns with no luck.


    here is a link to my table: http://roadrunner.cs.wcupa.edu/~tf577681/final/leagueLeaders.php
  • llhhyyllhhyy Posts: 4Questions: 0Answers: 0
    heres my code: part 1 of 2:

    [code]

    <?php
    require_once "statCalculations.php"
    ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">



    DataTables example




    body {
    padding: 15px;
    }
    #example {
    white-space: nowrap;
    }
    #example_enclosure {
    width: 900px;
    color: black;
    text-align: center;
    }
    /* the headers are in their own separate table with class='dataTable' */
    table.dataTable thead tr th {
    text-align: left;
    }
    table.dataTable thead th {
    text-align: center;
    /*padding: 3px 0px 3px 10px;
    cursor: pointer;*/
    /*DAM added to fix issue with dev FixedColumns*/
    background-color: grey;
    color: orange;
    height: 40px;
    }

    #statTable {
    background-color: #5E7C88;
    overflow: none;
    padding: 5px;
    border-radius: 12px;
    text-align: center;
    }
    tfoot {
    background-color: grey;
    color: orange;
    height: 40px;
    text-align: center;
    }
    h2 {
    color: #96C5FE;
    }
    .names {
    background-color: orange;
    }
    #warn {
    color: white;
    text-align: left;
    }







    $(document).ready(function(){
    var table = $('#example').dataTable( {

    "bPaginate": false, // no pagination
    "sScrollY": "215px", // vertical height
    "sScrollX": "100%",
    //"sScrollXInner": "100%",
    "bScrollCollapse": true, // add a scroll bar
    "bFilter": false, // turn off search filter
    "bInfo": false, // turn of info
    //"bAutoWidth": false,
    "aaSorting": [[ 1, "desc" ]],
    // "sAjaxSource": "_getData.php",
    //"sScrollX": "sX",
    /* "aoColumns": [
    { "sTitle": "Player", sWidth: '9%' },
    { "sTitle": "Date", sWidth: '9%' },
    { "sTitle": "Opponent", sWidth: '9%' },
    { "sTitle": "Results", sWidth: '9%' },
    { "sTitle": "Player", sWidth: '9%' },
    { "sTitle": "Date", sWidth: '9%' },
    { "sTitle": "Opponent", sWidth: '9%' },
    { "sTitle": "Results", sWidth: '9%' },
    { "sTitle": "Player", sWidth: '9%' },
    { "sTitle": "Points For" }
    ], */
    "sDom": 'Rlfrtip', // setting to allow column reordering
    "aoColumnDefs": [
    { "asSorting": [ "desc" ], "aTargets": [ 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,21,22,23,24,25,26 ] }
    ],

    });

    new FixedColumns( table, {
    "iLeftColumns": 2,

    });


    // bind a callback function to any sorting event (by clicking header)
    /* table.bind( 'sort', function(evt,obj) {
    var col = obj.aaSorting[0][0]; // the chosen column to sort
    if (col > 1) {
    //table.fnColReorder( col, 1 ); // move the column to column 1
    }
    });*/
    });



    [/code]
  • llhhyyllhhyy Posts: 4Questions: 0Answers: 0
    part 2:

    [code]


    <?php require_once "include/header.php" ?>


    <?php require_once "include/links.php" ?>



    Season 2 League Stats

    <!---->




    Player
    Wins




    <?php echo "Chris B"?>
    <?php echo $chrisWins?>



    <?php echo "Dave D"?>
    <?php echo $daveDWins?>


    <?php echo "Dave T"?>
    <?php echo $daveTWins?>



    <?php echo "Jason V"?>
    <?php echo $jasonWins?>



    <?php echo "John D"?>
    <?php echo $johnWins?>



    <?php echo "Rob P"?>
    <?php echo $robWins?>



    <?php echo "Tim F"?>
    <?php echo $timWins?>



    <?php echo "Todd K"?>
    <?php echo $toddWins?>





    Totals
    <?php echo $timWins +$daveTWins + $jasonWins + $toddWins + $johnWins +
    $daveDWins + $chrisWins + $robWins ?>

















    /* local JavaScript */
    function getSelf() { return "<?php echo basename($_SERVER['PHP_SELF'])?>"; }




    [/code]
  • llhhyyllhhyy Posts: 4Questions: 0Answers: 0
    part 2:

    [code]


    <?php require_once "include/header.php" ?>


    <?php require_once "include/links.php" ?>



    Season 2 League Stats

    <!---->




    Player
    Wins





    <?php echo "Chris B"?>
    <?php echo $chrisWins?>



    <?php echo "Dave D"?>
    <?php echo $daveDWins?>



    <?php echo "Dave T"?>
    <?php echo $daveTWins?>



    <?php echo "Jason V"?>
    <?php echo $jasonWins?>



    <?php echo "John D"?>
    <?php echo $johnWins?>



    <?php echo "Rob P"?>
    <?php echo $robWins?>



    <?php echo "Tim F"?>
    <?php echo $timWins?>



    <?php echo "Todd K"?>
    <?php echo $toddWins?>





    Totals
    <?php echo $timWins +$daveTWins + $jasonWins + $toddWins + $johnWins +
    $daveDWins + $chrisWins + $robWins ?>
    <?php echo $timLoss +$daveTLoss + $jasonLoss+ $toddLoss + $johnLoss +







    <!--Table may not function properly in Internet Exlporer. For best resutls use Chrome or Firefox.-->
    KO = Knockoff
    SKO = Standing Knockoff
    Exotic KO = All knockoffs (standing or not) of two or more

    <!--end Warn-->










    /* local JavaScript */
    function getSelf() { return "<?php echo basename($_SERVER['PHP_SELF'])?>"; }




    [code]
This discussion has been closed.