A sortable Bob Obringer view

You know what they say about customers: If you give them one finger, they’ll take your hand.

After implementing Bob Obringer’s approach to add page navigation to a view I get the request to make the columns sortable.

Normally I offer customers sortable columns as clickable headers in a table, like described here. But this approach makes the documents presented in the table part of the sorting. So if your table displays 30 documents based upon a server setting, only these 30 presented documents are part of the sorting process.

If you implement this approach in Bob’s solution which is based on showing only a subset of documents at a time the function will also only sort the documents presented at that time.

When looking at the parameter Notes adds when clicking a sortable Notes viewcolumn it will be

  • &ResortAscending=
  • &ResortDescending=

followed by the number of the column you clicked on.

Don’t ask why but this parameter seems to be displayed always before the number of documents shown, if you manually change the order of parameters it will present the same result. So:

  • &Count=30&ResortDescending=3 equeals
  • &ResortDescending=3&Count=30

So in order to make a column in Bob’s approach sortable you need to rewrite the follwoing sections in the JS part:

function buildLink(pageNum, text) {
linkHTML = linkHTML + “onclick=document.location.href='” + viewAlias + “?OpenView&Start=” + startLinkDoc + “&Count=” + docsPerPage + “‘>” + text + “</td>”;



function buildLink(pageNum, text) {

linkHTML = linkHTML + “onclick=document.location.href='” + viewAlias + “?OpenView” + sortQuery + “&Start=” + startLinkDoc + “&Count=” + docsPerPage + “‘>” + text + “</td>”;



function getPage(event, field) {
document.location.href = dbPath + viewAlias + “?OpenView&start=” + (((newPage – 1) * docsPerPage) + 1) + “&count=” + docsPerPage



function getPage(event, field) {

document.location.href = dbPath + viewAlias + “?OpenView” + sortQuery + “&start=” + (((newPage – 1) * docsPerPage) + 1) + “&count=” + docsPerPage


So what is in the sortQuery variable?

In the HTMLHead Content section I define:



@If(@Contains(Query_String_Decoded;”Ascending”);”&ResortAscending=” + varColumnAsc;
 @If(@Contains(Query_String_Decoded;”Descending”);”&ResortDescending=” + varColumnDesc;””));

I also define in the HTMLHead Content:

“<script language=’javascript’>” + @NewLine +
 “var sortQuery = ‘” + sortQuery + “‘” + @NewLine +

The code assumes you have less than 100 columns in the view. If you have less than 10 columns for example 9:


results in ‘9&’, ‘&’ is the beginning of the next parameter ‘&Count=’.

Therefor I correct this with:


so the ‘&’ gets cut.

sortable column


2 thoughts on “A sortable Bob Obringer view

  1. Farvish 2007-May-22 / 9:04 am

    We have incorporated the flat view pagination of Bob in out application. Is there a soulution for the Categorized views? If there is pls let us know. If need be we can buy the product also. Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s