Changeset 79

Show
Ignore:
Timestamp:
08/02/06 00:58:48 (4 years ago)
Author:
mischa
Message:

move functions where they belong, in the parent class

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/datasource.js

    r66 r79  
    8888  }, 
    8989 
    90   // aliases for use with unpaginated data sources 
    9190  totalLength: function () { 
    9291    return this.allData().length; 
    9392  }, 
     93 
    9494  allData: function () { 
    95     return this.theData; 
     95    var theData = this.theData; 
     96 
     97    if (this.dataField && theData) 
     98      theData = theData[this.dataField]; 
     99 
     100    return theData; 
    96101  }, 
    97102 
  • trunk/paginateddatasource.js

    r38 r79  
    55// paginated, simply call myDataSource.makePaginated(). 
    66DataSource.prototype.extend({ 
     7  makePaginated: function (opts) { 
     8      if (opts) 
     9          this.dataField = opts.dataField; 
    710 
    8   // returns the length of the entire data array, not just the subset on the current page 
    9   totalLength: function () { 
    10     return this.theData.length; 
    11   }, 
    12  
    13   makePaginated: function () { 
    1411    this.extend({ 
    1512 
    1613  // returns how many pages there are 
    1714  getPageCount: function () { 
    18     return Math.ceil(this.length() / this.itemsPerPage) || 1; 
     15    return Math.ceil(this.totalLength() / this.getItemsPerPage()) || 1; 
    1916  }, 
    2017 
     
    7067    var theData = this.theData; 
    7168 
     69    if (this.dataField && theData) { 
     70        theData = theData[this.dataField]; 
     71    } 
     72 
    7273    if (!theData || !theData.length) 
    7374      return [];