Translations of this page:

Instantiating

Instantiating a cachetable needs following arguments:

  • 1. Id of the DOM-Element in into which the table should be drawn
  • 2. dataProvider : An Object providing at least these two methods:
    • getData(from, count) must return count records starting at position from. May work async
    • getIdList(from, count) must return the count Ids starting at position from. Must work sync
  • 3. listCount how many records should be displayed on one page, independent on the number of the totally available records (e.g. show 30 records in the table, although if in the database 20'000 are available)
  • 4. Cols a numeric array of the column names.

Example:

var cols = ['id', 'name', 'firstname'];
var dp = new my_dataProvider();
cacheTable = new cachetable('table', dp, 25, cols);

Displaying data

Different to the “normal” datatable or the edit_table, you don't have to directly pass the records to be shown to the cachetable. What you have to do is telling the cahchetable how many records are totally available, this is done by calling the method dataChanged. After this the cachtable will call the dataProvider (passed in the constructor) to fetch the needed records, i.e. these in the visible area (e.g. index 0 - 24 if you have a listcount of 25). If the user afterwards starts scrolling through the table, the cachtable will check if all data for the newly displayed area are loaded and otherwise it calls again the dataProvider to get the needed data.

Example:

var matchCount = this.getMatchCount();  // Should be a function that returns the total number of records in your datasource
cacheTable.dataChanged(matchCount);
 
en/dev/cachetable.txt · Last modified: 10.12.2007 11:41 by kaegi
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki