Christopher Mann
unread,Apr 19, 2011, 4:27:57 PM4/19/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to MochiKit
Hi Folks,
I added a way to specify the default sort column and order. The docs
don't seem to indicate any prescribed way to do this, and looking
through the source code I see the initial table sort was always on
column 0, forward order.
So add this to your HTML:
<div id="sortable_table_sortkey" style="display: none;">1</div>
<div id="sortable_table_sortorder" style="display: none;">reverse</
div>
Then search for this in sortable_tables.js (around line 116):
// do initial sort on first column
this.drawSortedRows(this.sortkey, true, false);
And replace with:
// do initial sort on first column
// this.drawSortedRows(this.sortkey, true, false);
// use the global sortkey by default
var initial_sortkey = this.sortkey;
// if a sortkey is specified use that instead
if (specified_sortkey =
document.getElementById("sortable_table_sortkey"))
{
initial_sortkey = specified_sortkey.innerHTML;
};
// use 'true' (forward) sort order by default
var initial_sortorder = true;
// if a sortorder is specified use that instead
if (specified_sortorder =
document.getElementById("sortable_table_sortorder"))
{
if (specified_sortorder.innerHTML == "reverse")
{
initial_sortorder = false;
}
else if (specified_sortorder.innerHTML == "forward")
{
initial_sortorder = true;
}
else
{
initial_sortorder = false;
};
};
this.drawSortedRows(initial_sortkey, initial_sortorder,
false);
Hope that helps some people.
Thanks for developing MochiKit!