A couple of notes:
1 To get $attributes used in his example do this:
c_longint($attributes)
$attributes := merge collections(form variables; query params)
2) If no records are returned in the rowset and you still execute the
batch code, then $batch("Start") and $batch("End") will be both be 0.
Therefore the for loop will execute at least once giving you an empty
row.
Just one way around this would be to test for these values and if
true increment $start ($start++) so that the loop never executes.
Hope this helps.
M.
On 25 Sep 2005, at 16:34, Aparajita Fishman wrote:
I've successfully created a RowSet (very nice) and I have created
a Batch from the RowSet (the links are there, but they don't limit
the rowset).
Where in the documentation does it tell me how to use the two
together? The Batch must somehow limit the RowSet to a subset, but
how?
Sorry, I forgot to document how to use the batch to loop through
the RowSet. Here's a typical example, assuming $qryContacts is a
RowSet you already created:
<%
// Get the starting index from the query string. If it wasn't there
// the num() of it will be zero, so force it to 1.
$start := max of(num($attributes{"bst"}); 1)
// Now make the batch
$batch := Batch.NewFromRowSet($qryContacts; 10; $start; 0; 3)
// Setup the link info, make the links
$previous := "<< Previous|batch-previous"
$pages := " "
$next := "Next >>|batch-next"
$needPages := $batch->makeFuseboxLinks($previous; $pages; $next;
$attributes; ""; ""; "b")
%>
<table>
<tr>
<th>Name</th>
<th>Phone</th>
</tr>
<%
$row := $qryContacts->getRow
$alt := true
for ($i; $batch{"start"}; $batch{"end"})
$qryContacts->gotoRow($i)
$alt := not($alt)
%>
<tr <%=choose($alt; "class=\"row-alt\""; "")%>>
<td><%=$row{"name"}%></td>
<td><%=$row{"phone"}%></td>
</tr>
<% end for %>
</table>
Regards,
Aparajita
www.aparajitaworld.com
"If you dare to fail, you are bound to succeed."
- Sri Chinmoy | www.srichinmoylibrary.com
_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/
_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/