I’m trying to collect the current, previous and next record values from table in my template.
I’m able to get the next value, but can’t get the past value and having difficulties getting the last record.
results.each(function(index) {
var field, nfield, pfield, result = "";
var nindex, pindex, tlength;
tlength = record.tables["DetailLine"].length;
if (index == 0){
pindex = index;
} else {
pindex = index -1;
}
if (index == tlength){
nindex = index;
} else {
nindex = index +1;
}
field = record.tables["DetailLine"][index].fields["VPN"];
if (nindex != index){
nfield = record.tables["DetailLine"][nindex].fields["VPN"];
} else {
nfield = "NULL";
}
if (pindex != index){
pfield = record.tables["DetailLine"][pindex].fields["VPN"];
} else {
pfield = "NULL";
}
result = "Current Value: " + field + " Next Value: " + nfield + " Previous Value: " + pfield;
this.html(result);
});