Link to "Changing the default sort on pages that support..."

Message board links from 2010 as taken from the Internet Wayback Machine pages.
Post Reply
User avatar
admin
Site Admin
Posts: 159
Joined: Mon Aug 26, 2013 3:47 pm

Re: Link to "Changing the default sort on pages that support

Post by admin »

08-21-2009 8:44 PM
mikehall
Top 10 Contributor
Joined on 08-09-2009
Chandler, AZ
Posts 456

Changing the default sort on pages that support dynamic sorting.
Reply Contact

This question came up in a few emails: How can you change the sort order on pages like the Weekly Results? That particular page, like most others, initially shows the results sorted by player name. You can click on several column headers to dynamically sort the display by different criteria, but what if you want to change the initial display? Say, to show it sorted by score?

There is a pretty simple way to do that, using the existing JavaScript code. First, take a look at the JavaScript code embedded in the weeklyResults.asp file that sets up the sort feature:

Code: Select all

    	<script type="text/javascript">//<![CDATA[
    	//=========================================================================
    	// Define the results table sort commands.
    	//=========================================================================
    	var resultsNameSort = {
    		initialSort : true,
    		tbodyID     : "resultsBody",
    		theadID     : "resultsHead",
    		sortColumns : [
    			{ column : 0, descending : false }
    		],
    		highlightColumns : {
    			bodyColumns : [],
    			headColumns : []
    		}
    	}

    	// ...and so on...

    	var resultsScoreSort = {
    		tbodyID     : "resultsBody",
    		theadID     : "resultsHead",
    		sortColumns : [
    			{ column : -1, descending : true  },
    			{ column : -3, descending : false },
    			{ column :  0, descending : false }
    		],
    		highlightColumns : {
    			bodyColumns : [-3, -2, -1],
    			headColumns : [-2, -1]
    		}
    	}
    	//]]></script>
This code defines a variable with the parameters for each of the sortable columns. The one of interest here is resultsScoreSort. By adding a few lines of JavaScript code, you can run that sort as soon as the page loads:

Code: Select all

    	// Execute the score sort as soon as the page loads.
    	domUtils.onready(function() {
    		tableSort.sort(resultsScoreSort);
    	});
This basically has the effect of clicking on the "Score" header on the page, but it does it when the page initially loads.

If you'd rather not have the score column highlighted at first, you can accomplish that with a little more coding:

Code: Select all

    	/* Sort results by score on page load. */

    	// Define the new sort command. This is based on the existing score sort
    	// command but does not highlight any columns.
    	var resultsCustomSort = {
    		tbodyID     : "resultsBody",
    		theadID     : "resultsHead",
    		sortColumns : [
    <%	if USE_CONFIDENCE_POINTS then %>
    			{ column : -2, descending : true  },
    <%	else %>
    			{ column : -1, descending : true  },
    <%	end if %>
    			{ column : -3, descending : false },
    			{ column :  0, descending : false }
    		],
    		highlightColumns : {
    			bodyColumns : [],
    			headColumns : []
    		}
    	}

    	// Execute the new score sort as soon as the page loads.
    	domUtils.onready(function() {
    		tableSort.sort(resultsCustomSort);
    		resultsNameSort.initialSort = false;
    		document.getElementById(resultsCustomSort.tbodyID).lastSortCommand = resultsScoreSort;
    	});
Note the VBScript lines (<% ... %>). These are necessary because the columns that need to be sorted differ based on whether or not confidence points are being used.

The above code creates a new sort command object, resultsCustomSort. It's identical to resultsScoreSort except that there are no highlight columns defined. The last two lines of code clean up the UI behaviour, so that if the user clicks on the "Name" or "Score" header it will properly toggle the sort order of those columns.
Filed under: customization, sort
08-22-2009 4:38 PM In reply to
drizzt09
Top 10 Contributor
Joined on 08-22-2009
Ontario Canada
Posts 322

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

worked excellent for me, thanks
08-25-2009 8:15 AM In reply to
drizzt09
Top 10 Contributor
Joined on 08-22-2009
Ontario Canada
Posts 322

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

also in the weeklySummery.asp I edited it slightly for the Individual Weekly Pool Statistics

same as previous command except the bolded parts

Code: Select all

           /* Sort results by score on page load. */

           // Define the new sort command. This is based on the existing score sort
           // command but does not highlight any columns.
           var resultsCustomSort = {
                   tbodyID     : "resultsBody",
                   theadID     : "resultsHead",
                   sortColumns : [
    <%      if USE_CONFIDENCE_POINTS then %>
                           { column : -2, descending : true  },
    <%      else %>
                           { column : -1, descending : true  },
    <%      end if %>
                           { column : -3, descending : false },
                           { column :  0, descending : false }
                   ],
                   highlightColumns : {
                           bodyColumns : [],
                           headColumns : []
                   }
           }

           // Execute the new score sort as soon as the page loads.
           domUtils.onready(function() {
                   tableSort.sort(statisticsPicksSort);
                   resultsNameSort.initialSort = false;
                   document.getElementById(resultsCustomSort.tbodyID).lastSortCommand =
    statisticsPicksSort;
           });
08-25-2009 12:21 PM In reply to
Smokey Jones
Top 10 Contributor
Joined on 08-24-2009
Posts 84

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

drizz,

Where exactly does your code go? I can't seem to figure out where to put it.
08-25-2009 1:45 PM In reply to
drizzt09
Top 10 Contributor
Joined on 08-22-2009
Ontario Canada
Posts 322

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

Code: Select all

        //=========================================================================
        // Define the statistics table sort commands.
        //=========================================================================
        var statisticsNameSort = {
            initialSort : true,
            tbodyID     : "statisticsBody",
            theadID     : "statisticsHead",
            sortColumns : [
                { column : 0, descending : false }
            ],
            highlightColumns : {
                bodyColumns : [],
                headColumns : []
            }
        }
        var statisticsPlayedSort = {
            tbodyID     : "statisticsBody",
            theadID     : "statisticsHead",
            sortColumns : [
                { column : 1, descending : true },
                { column : 0, descending : false }
            ],
            highlightColumns : {
                bodyColumns : [1],
                headColumns : [1]
            }
        }
        var statisticsWonSort = {
            tbodyID     : "statisticsBody",
            theadID     : "statisticsHead",
            sortColumns : [
                { column : 2, descending : true },
                { column : 0, descending : false }
            ],
            highlightColumns : {
                bodyColumns : [2],
                headColumns : [2]
            }
        }
        var statisticsCostSort = {
            tbodyID     : "statisticsBody",
            theadID     : "statisticsHead",
            sortColumns : [
                { column : 3, descending : true },
                { column : 0, descending : false }
            ],
            highlightColumns : {
                bodyColumns : [3],
                headColumns : [3]
            }
        }
        var statisticsWinningsSort = {
            tbodyID     : "statisticsBody",
            theadID     : "statisticsHead",
            sortColumns : [
                { column : 4, descending : true },
                { column : 0, descending : false }
            ],
            highlightColumns : {
                bodyColumns : [4],
                headColumns : [4]
            }
        }
        var statisticsNetSort = {
            tbodyID     : "statisticsBody",
            theadID     : "statisticsHead",
            sortColumns : [
                { column : 5, descending : true },
                { column : 0, descending : false }
            ],
            highlightColumns : {
                bodyColumns : [5],
                headColumns : [5]
            }
        }
        var statisticsPicksSort = {
            tbodyID     : "statisticsBody",
            theadID     : "statisticsHead",
            sortColumns : [
    <%    if ENABLE_OVERALL_WEEKLY then %>
                { column : 6, descending : true },
    <%    else %>
                { column : 7, descending : true },
    <%    end if %>
                { column : 0, descending : false }
            ],
            highlightColumns : {
                bodyColumns : [6, 7],
                headColumns : [6]
            }
        }
    <%    if USE_CONFIDENCE_POINTS then %>
        var statisticsPointsSort = {
            tbodyID     : "statisticsBody",
            theadID     : "statisticsHead",
            sortColumns : [
                { column : 8, descending : true },
                { column : 0, descending : false }
            ],
            highlightColumns : {
                bodyColumns : [8],
                headColumns : [7]
            }
        }
    <%    end if %>
           /* Sort results by score on page load. */

           // Define the new sort command. This is based on the existing score sort
           // command but does not highlight any columns.
           var resultsCustomSort = {
                   tbodyID     : "resultsBody",
                   theadID     : "resultsHead",
                   sortColumns : [
    <%      if USE_CONFIDENCE_POINTS then %>
                           { column : -2, descending : true  },
    <%      else %>
                           { column : -1, descending : true  },
    <%      end if %>
                           { column : -3, descending : false },
                           { column :  0, descending : false }
                   ],
                   highlightColumns : {
                           bodyColumns : [],
                           headColumns : []
                   }
           }

           // Execute the new score sort as soon as the page loads.
           domUtils.onready(function() {
                   tableSort.sort(statisticsPicksSort);
                   resultsNameSort.initialSort = false;
                   document.getElementById(resultsCustomSort.tbodyID).lastSortCommand =
    statisticsPicksSort;
           });
        //]]></script>
08-25-2009 2:21 PM In reply to
Smokey Jones
Top 10 Contributor
Joined on 08-24-2009
Posts 84

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

I'm having some issues with that code drizz. First, when I load the page, I get an error:

Message: 'resultsNameSort' is undefined

I figured that one out. In the line

Code: Select all

resultsNameSort.initialSort = false;
should be

Code: Select all

statisticsNameSort.initialSort = false;
So I changed that and now I get the following error:

Message: 'document.getElementById(...)' is null or not an object

And to add salt to the wound, the columns are highlighted upon page load. I'm using IE8 and if I remove the line

Code: Select all

document.getElementById(resultsCustomSort.tbodyID).lastSortCommand = statisticsPicksSort; 
it loads without error although the columns are still highlighted.

WAIT!!! I figured it out! Or at least some of it.

Code: Select all

                   tbodyID     : "resultsBody",
                   theadID     : "resultsHead",
should be

Code: Select all

                   tbodyID     : "statisticsBody",
                   theadID     : "statisticsHead",
I still have the issue of the columns being highlighted on page load.
08-25-2009 5:56 PM In reply to
drizzt09
Top 10 Contributor
Joined on 08-22-2009
Ontario Canada
Posts 322

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

Ill have to test it in another browser, I just took mikes code for the results page and changed the 2 lines I thought appropriate, worked in firefox. Ill check in IE and get back to you, or if Mike could also shed some light on it too. nah its working in IE7 as well

Individual Weekly Pool Statistics
Name Played Won Cost Winnings Net Overall Picks
Overall Pot: $9.00
test 2 1 $6.00 $4.50 -$1.50 14/26 (0.538)
brennon 2 1 $6.00 $4.50 -$1.50 12/26 (0.462)
trinh 2 0 $6.00 $0.00 -$6.00 9/26 (0.346)


08-25-2009 6:46 PM In reply to
Smokey Jones
Top 10 Contributor
Joined on 08-24-2009
Posts 84

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

I fixed the issues that I was having except for the highlighting of the columns. Still not sure why that's not working.
08-25-2009 7:32 PM In reply to
drizzt09
Top 10 Contributor
Joined on 08-22-2009
Ontario Canada
Posts 322

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

so what all coding changes did you make, Ill put them in and see what it does to mine. I also tested in chrome, still wors with my original coding. I do see the OVERALL PICKS slightly highlighted, doesnt bother me, but I know its not supposed to be.
08-26-2009 5:40 AM In reply to
Smokey Jones
Top 10 Contributor
Joined on 08-24-2009
Posts 84

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

Code: Select all

           /* Sort results by score on page load. */

           // Define the new sort command. This is based on the existing score sort
           // command but does not highlight any columns.
           var resultsCustomSort = {
                   tbodyID     : "statisticsBody",
                   theadID     : "statisticsHead",
                   sortColumns : [
    <%      if USE_CONFIDENCE_POINTS then %>
                           { column : -2, descending : true  },
    <%      else %>
                           { column : -1, descending : true  },
    <%      end if %>
                           { column : -3, descending : false },
                           { column :  0, descending : false }
                   ],
                   highlightColumns : {
                           bodyColumns : [],
                           headColumns : []
                   }
           }

           // Execute the new score sort as soon as the page loads.
           domUtils.onready(function() {
                   tableSort.sort(statisticsPicksSort);
                   statisticsNameSort.initialSort = false;
                   document.getElementById(resultsCustomSort.tbodyID).lastSortCommand = statisticsPicksSort;
           });
        //]]></script>
The items in bold is all I changed. The highlighted columns issue doesn't bother me either, just wanted to let you (and MikeH) know that that function doesn't work here although it does sort on page load.
08-26-2009 7:56 AM In reply to
mikehall
Top 10 Contributor
Joined on 08-09-2009
Chandler, AZ
Posts 456

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

Try this (note the highlighted variable names, they need to match)

Code: Select all

           /* Sort results by score on page load. */

           // Define the new sort command. This is based on the existing score sort
           // command but does not highlight any columns.
           var statisticsCustomSort = {
                   tbodyID     : "statisticsBody",
                   theadID     : "statisticsHead",
                   sortColumns : [
    <%      if USE_CONFIDENCE_POINTS then %>
                           { column : -2, descending : true  },
    <%      else %>
                           { column : -1, descending : true  },
    <%      end if %>
                           { column : -3, descending : false },
                           { column :  0, descending : false }
                   ],
                   highlightColumns : {
                           bodyColumns : [],
                           headColumns : []
                   }
           }

           // Execute the new score sort as soon as the page loads.
           domUtils.onready(function() {
                   tableSort.sort(statisticsCustomSort);
                   statisticsNameSort.initialSort = false;
    <%      if USE_CONFIDENCE_POINTS then %>
                   document.getElementById(statisticsCustomSort.tbodyID).lastSortCommand = statisticsPointsSort;
    <%      else %>
                   document.getElementById(statisticsCustomSort.tbodyID).lastSortCommand = statisticsPicksSort;
           });
    <%      end if %>

08-26-2009 9:16 AM In reply to
drizzt09
Top 10 Contributor
Joined on 08-22-2009
Ontario Canada
Posts 322

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

Excellent, that did it
08-26-2009 11:25 AM In reply to
Smokey Jones
Top 10 Contributor
Joined on 08-24-2009
Posts 84

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

Awesome! Thanks for the help drizz and Mike!! I've been wanting this sorting for awhile!
08-26-2009 12:00 PM In reply to
drizzt09
Top 10 Contributor
Joined on 08-22-2009
Ontario Canada
Posts 322

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

np, but it was all mike. I just took his original code and edited a few things and moved over tot he other page. thought it worked but apperantly not, and mike to the rescue again.
09-01-2009 6:05 AM In reply to
SQLDude
Top 50 Contributor
Joined on 09-01-2009
Posts 5

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact
Has anyone done this for poolresults.asp using the Score column and the TB Diff column as one would sort it to show the up to date leader board? Just thought I would ask before trying to tackle this myself since my Javascript is just not that advanced.

Page 1 of 2 (29 items) 1 2 Next >
User avatar
admin
Site Admin
Posts: 159
Joined: Mon Aug 26, 2013 3:47 pm

Re: Link to "Changing the default sort on pages that support

Post by admin »

09-01-2009 12:05 PM In reply to
drizzt09
Top 10 Contributor
Joined on 08-22-2009
Ontario Canada
Posts 322

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

I dont have a poolresults.asp

is that in the old version?
09-01-2009 2:28 PM In reply to
mikehall
Top 10 Contributor
Joined on 08-09-2009
Chandler, AZ
Posts 456

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

That's v2.3, it's called weeklyResults.asp in the new version.
09-12-2009 5:45 PM In reply to
timb24
Top 50 Contributor
Joined on 08-25-2009
Posts 7

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

I'm running v2.3. All I did was change the body statement in poolResults.asp to be <body onload="sortResults('Score')"> and poolSummary.asp to be <body onload="sortStats('Points')">. The column is highlighted, but I'm ok with that - it kind of makes it obvious to the user that that's how the table is sorted.
11-24-2009 1:32 PM In reply to
drizzt09
Top 10 Contributor
Joined on 08-22-2009
Ontario Canada
Posts 322

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

mikehall:

Try this (note the highlighted variable names, they need to match)

Code: Select all

              /* Sort results by score on page load. */

               // Define the new sort command. This is based on the existing score sort
               // command but does not highlight any columns.
               var statisticsCustomSort = {
                       tbodyID     : "statisticsBody",
                       theadID     : "statisticsHead",
                       sortColumns : [
        <%      if USE_CONFIDENCE_POINTS then %>
                               { column : -2, descending : true  },
        <%      else %>
                               { column : -1, descending : true  },
        <%      end if %>
                               { column : -3, descending : false },
                               { column :  0, descending : false }
                       ],
                       highlightColumns : {
                               bodyColumns : [],
                               headColumns : []
                       }
               }

               // Execute the new score sort as soon as the page loads.
               domUtils.onready(function() {
                       tableSort.sort(statisticsCustomSort);
                       statisticsNameSort.initialSort = false;
        <%      if USE_CONFIDENCE_POINTS then %>
                       document.getElementById(statisticsCustomSort.tbodyID).lastSortCommand = statisticsPointsSort;
        <%      else %>
                       document.getElementById(statisticsCustomSort.tbodyID).lastSortCommand = statisticsPicksSort;
               });
        <%      end if %>
This worked for 3.0 but not working right for 3.1. The Weekly results is working, just not Weekly Summery. Can you crack this one for me and Im ready to make the move... I hope... LOL
11-24-2009 6:25 PM In reply to
mikehall
Top 10 Contributor
Joined on 08-09-2009
Chandler, AZ
Posts 456

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

I'll take a look, which column are you trying to sort?
11-24-2009 6:40 PM In reply to
drizzt09
Top 10 Contributor
Joined on 08-22-2009
Ontario Canada
Posts 322

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

overall picks



thanks
11-24-2009 6:50 PM In reply to
mikehall
Top 10 Contributor
Joined on 08-09-2009
Chandler, AZ
Posts 456

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

Ok, try this:

Code: Select all

           /* Sort results by score on page load. */

           // Define the new sort command. This is based on the existing score sort
           // command but does not highlight any columns.
           var statisticsCustomSort = {
                   tbodyID     : "statisticsBody",
                   theadID     : "statisticsHead",
    <%    if ENABLE_OVERALL_WEEKLY then %>
            sortColumns : [
                { column : 6, descending : true },
                { column : 0, descending : false }
            ],
    <%    else %>
            sortColumns : [
                { column : 7, descending : true },
                { column : 0, descending : false }
            ],
    <%    end if %>
            highlightColumns : {
                bodyColumns : [],
                headColumns : []
            }
           }

           // Execute the new score sort as soon as the page loads.
           domUtils.onready(function() {
                   tableSort.sort(statisticsCustomSort);
                   statisticsNameSort.initialSort = false;
    <%      if USE_CONFIDENCE_POINTS then %>
                   document.getElementById(statisticsCustomSort.tbodyID).lastSortCommand = statisticsPointsSort;
    <%      else %>
                   document.getElementById(statisticsCustomSort.tbodyID).lastSortCommand = statisticsPicksSort;
           });
    <%      end if %>

11-24-2009 8:00 PM In reply to
drizzt09
Top 10 Contributor
Joined on 08-22-2009
Ontario Canada
Posts 322

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

You the man as usual.

Perfect, thanks
12-03-2009 2:15 PM In reply to
kamokid
Top 10 Contributor
Joined on 08-27-2009
Posts 56

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

Since we are talking sorting how would I get it to sort so people with a scores 14/16 are higher than people that are 120/176 on the Individual Weekly Pool Stats. I know its a higher % but still not better if only have 14 wins total. Any help would be good. Thanks
12-03-2009 5:27 PM In reply to
mikehall
Top 10 Contributor
Joined on 08-09-2009
Chandler, AZ
Posts 456

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

The way the "click" sort is set up by default depends on whether you have the overall pot option set or not, If it's off, it sorts on the percent column and if it's on, it sorts by the correct/total picks column. That's because the overall award is based on total correct rather than percent correct.

The code in the page script looks like this:

Code: Select all

        var statisticsPicksSort = {
            tbodyID     : "statisticsBody",
            theadID     : "statisticsHead",
    <%    if ENABLE_OVERALL_WEEKLY then %>
            sortColumns : [
                { column : 6, descending : true },
                { column : 0, descending : false }
            ],
            highlightColumns : {
                bodyColumns : [6, 7, 8],
                headColumns : [ 6 ]
            }
    <%    else %>
            sortColumns : [
                { column : 7, descending : true },
                { column : 0, descending : false }
            ],
            highlightColumns : {
                bodyColumns : [6, 7],
                headColumns : [ 6 ]
            }
    <%    end if %>
So for total correct, you want to sort column index 6 and for percent correct you want to sort column index 7 (column 0 is the leftmost one, the player name, and is used as a secondary sort index).

If you want, you could just change the code above to sort on column 6 (or 7) in both cases.
02-01-2010 12:53 PM In reply to
drizzt09
Top 10 Contributor
Joined on 08-22-2009
Ontario Canada
Posts 322

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

mikehall:

Ok, try this:

Code: Select all

              /* Sort results by score on page load. */

               // Define the new sort command. This is based on the existing score sort
               // command but does not highlight any columns.
               var statisticsCustomSort = {
                       tbodyID     : "statisticsBody",
                       theadID     : "statisticsHead",
        <%    if ENABLE_OVERALL_WEEKLY then %>
                sortColumns : [
                    { column : 6, descending : true },
                    { column : 0, descending : false }
                ],
        <%    else %>
                sortColumns : [
                    { column : 7, descending : true },
                    { column : 0, descending : false }
                ],
        <%    end if %>
                highlightColumns : {
                    bodyColumns : [],
                    headColumns : []
                }
               }

               // Execute the new score sort as soon as the page loads.
               domUtils.onready(function() {
                       tableSort.sort(statisticsCustomSort);
                       statisticsNameSort.initialSort = false;
        <%      if USE_CONFIDENCE_POINTS then %>
                       document.getElementById(statisticsCustomSort.tbodyID).lastSortCommand = statisticsPointsSort;
        <%      else %>
                       document.getElementById(statisticsCustomSort.tbodyID).lastSortCommand = statisticsPicksSort;
               });
        <%      end if %>


OK using this for the NHL site too. Its sorting by OVERALL PICKS on startup, but secondary sort is by NAME. how do we make it so secondary sort will be by the WON column? then 3rd to by NAME.
02-01-2010 3:53 PM In reply to
mikehall
Top 10 Contributor
Joined on 08-09-2009
Chandler, AZ
Posts 456

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

The format for that is:

Code: Select all

    sortColumns : [
                { column :  4, descending : false },
                { column : -1, descending : false },
                { column :  3, descending : true  },
                { column :  0, descending : false },
                   ...
            ],
where each { column : i, descending : true|false } represents one level. For any two table rows, the sorting code will try the first. If the columns are equal it tries the second and so on.

The column number represents the cell index of the table row: 0 is the leftmost cell, 1 is the second from the left and so on. You can use negative values to count from the right-hand side: -1 for the rightmost cell, -2 for the second from the right, etc.

The descending flag sets the sort order. False means sort low to high, true means sort high to low.

The other part is the highlighting:

Code: Select all

    highlightColumns : {
                bodyColumns : [1, 2],
                headColumns : [1]
            }
For this, it's just a list of cell indexes. One list for the body and one for the header. While debugging you might find it useful to highlight the same columns you're sorting on:

Code: Select all

    sortColumns : [
                { column :  4, descending : false },
                { column : -1, descending : false },
                { column :  3, descending : true  },
                { column :  0, descending : false },
            ],

     highlightColumns : {
                bodyColumns : [4, -1, 3, 0]
                headColumns : []
            }

02-03-2010 10:38 PM In reply to
drizzt09
Top 10 Contributor
Joined on 08-22-2009
Ontario Canada
Posts 322

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

ok got it. Now I understand how that works. I inserted the green part and it worked. thanks.

Code: Select all

           /* Sort results by score on page load. */

           // Define the new sort command. This is based on the existing score sort
           // command but does not highlight any columns.
           var statisticsCustomSort = {
                   tbodyID     : "statisticsBody",
                   theadID     : "statisticsHead",
    <%    if ENABLE_OVERALL_WEEKLY then %>
            sortColumns : [
                { column : 6, descending : true },
                { column : 2, descending : true },
                { column : 0, descending : false }
            ],
    <%    else %>
            sortColumns : [
                { column : 7, descending : true },
                { column : 0, descending : false }
            ],
    <%    end if %>
            highlightColumns : {
                bodyColumns : [],
                headColumns : []
            }
           }

           // Execute the new score sort as soon as the page loads.
           domUtils.onready(function() {
                   tableSort.sort(statisticsCustomSort);
                   statisticsNameSort.initialSort = false;
    <%      if USE_CONFIDENCE_POINTS then %>
                   document.getElementById(statisticsCustomSort.tbodyID).lastSortCommand = statisticsPointsSort;
    <%      else %>
                   document.getElementById(statisticsCustomSort.tbodyID).lastSortCommand = statisticsPicksSort;
           });
    <%      end if %>
10-07-2010 1:56 PM In reply to
drizzt09
Top 10 Contributor
Joined on 08-22-2009
Ontario Canada
Posts 322

Re: Changing the default sort on pages that support dynamic sorting.
Reply Contact

last posting while including:

{ column : 2, descending : true },

is not working on 4.0 weeklySummery.asp

Name Played Won Cost Winnings Net Overall Picks

test1 4 1 $12.00 $12.00 $0.00 31/61 (0.508)

test4 4 1 $12.00 $12.00 $0.00 31/61 (0.508)

test2 4 0 $12.00 $0.00 -$12.00 30/61 (0.492)

test3 4 2 $12.00 $24.00 $12.00 30/61 (0.492)

As you can see, test2 and test3 are equal(overall picks) but test3 "should" be in 3rd place do you having won twice and test2 has won 0.

I have tried: { column : 2, descending : false }, as well but nothing. Any idea?

Page 2 of 2 (29 items) < Previous 1 2
Post Reply