[SOLUTION] ViewNextPage in $$SearchTemplate form

Hallo,

I had problems with ViewNextPage, EndView, ViewPreviousPage @DbCommands on my $$SearchTemplateDefault form with $$ViewBody field. So I wrote some JavaScript code that is working instead of that.

I hope it will be helpfull for somebody:

//

//////////////////////////

function viewNext(){

var url = window.location.href;

var total = parseInt(document.forms[0].elements[‘TotalHits’].value);

var count = parseInt(document.forms[0].elements[‘Count’].value);

var start = parseInt(document.forms[0].elements[‘Start’].value);

var startnext = start + count;

if (startnext > total){return(“”);}

window.location = url.replace(‘&Start=’ + start.toString() + ‘&’, ‘&Start=’ + startnext.toString() + ‘&’);

}

//////////////////////////

function viewPrevious(){

var url = window.location.href;

var count = parseInt(document.forms[0].elements[‘Count’].value);

var start = parseInt(document.forms[0].elements[‘Start’].value);

var startnext = start - count;

if (start ==1) return(“”);

if (startnext < 0){startnext = 1;}

window.location = url.replace(‘&Start=’ + start.toString() + ‘&’, ‘&Start=’ + startnext.toString() + ‘&’);

}

//////////////////////////

function viewLast(){

var url = window.location.href;

var total = parseInt(document.forms[0].elements[‘TotalHits’].value);

var count = parseInt(document.forms[0].elements[‘Count’].value);

var start = parseInt(document.forms[0].elements[‘Start’].value);

var startnext = start

while ((startnext + count) < total){

startnext = startnext + count;

}

if (total < count) return(“”);

window.location = url.replace(‘&Start=’ + start.toString() + ‘&’, ‘&Start=’ + startnext.toString() + ‘&’);

}

//////////////////////////

function viewFirst(){

var url = window.location.href;

var start = parseInt(document.forms[0].elements[‘Start’].value);

var startnext = 1;

if (start ==1) return(“”);

window.location = url.replace(‘&Start=’ + start.toString() + ‘&’, ‘&Start=’ + startnext.toString() + ‘&’);

}

//</JS code>

Then in onClick events of the Hotspots I call:

viewFirst();

viewPrevious();

viewNext();

viewLast();

Regards

Konrad


Keywords: @DbCommand(“Domino”; “EndView”), @DbCommand(“Domino”; “ViewNextPage”), @DbCommand(“Domino”; “ViewPreviousPage”), $$ViewTemplateDefault, $$ViewTemplate, $$ViewBody

Subject: [SOLUTION] ViewNextPage in $$SearchTemplate form

What about viewNth() ? :slight_smile:

Subject: (Bug) Upgrade

Replace line in viewLast function:while ((startnext + count) < total){

by line:

while ((startnext + count) <= total){

Sorry for mistake :slight_smile:

Konrad

Subject: RE: (Bug) Upgrade

thanks Konrad. I have used this code for one of my client… its realy working.

If column sorting is there, this code will not work.