Christopher Mann
2011-04-19 20:27:57 UTC
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!
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!
--
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to mochikit+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en.
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to mochikit+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en.