Web Hosting
We've partnered with HostGator for reliable, affordable hosting starting at $3.95/mon. Use coupon code "javascriptkit25" for 25% off any package.

Controlling the number of records displayed

Depending on the number of records (rows) in your Tabular Data Control, displaying them all at once can be overwhelming to the viewer. You may want to try and control how many records is displayed at once, breaking things up into a few pages.

- Number your rows

The easiest way to control how many rows is display at one time is by adding an extra row in your data file that numbers each row, then let the Filter property run loose using them. Still using our old student grades example: 


~1~|~George Chiang~|~83%~
~2~|~Bill Larson~|~69%~
~3~|~Jimmy Lin~|~94%~
~4~|~Mary Miller~|~59%~
~5~|~Jane Wood~|~89%~
~6~|~Terry Gray~|~72%~
~7~|~Andrew Dart~|~82%~

To display only the first 5 students initially is a no brainer:

<PARAM NAME="Filter" VALUE="studentid<=5">

- Determining how many rows exists in total

In order to dynamically break up the display of a TDC into multiple "pages", the key piece of information we need is the total number of rows in the data file. There are a number of ways to determine this, with the below being one of them:

tdc.recordset.moveLast() //move to end of data file
var totalrows=tdc.recordset.absolutePosition //determine position of last row. Returns 7.

You may need to call the above after the page has loaded to ensure the data file has completely downloaded before trying to determine the final row's position.

Copyright 1997-2014 JavaScript Kit. NO PART may be reproduced without author's permission.