Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] Method to select all rows in a data table (reverse of unselectAllRows)

Expand Messages
  • Satyam
    Can you file this, along the code, as a feature request at: http://sourceforge.net/tracker/?group_id=165715&atid=836479 That would allow the YUI team to keep
    Message 1 of 2 , Oct 31, 2007
    • 0 Attachment
      Can you file this, along the code, as a feature request at:
       
       
      That would allow the YUI team to keep track of it, otherwise it might fall through the cracks.
       
      Satyam
       
      ----- Original Message -----
      Sent: Wednesday, October 31, 2007 11:38 AM
      Subject: [ydn-javascript] Method to select all rows in a data table (reverse of unselectAllRows)

      I had some problems with yui missing the reverse method of unselectAllRows for dataTable.
      Hope you'll find it usefull 
      Haven't tested much, but works for me.

      /**
      * Convenience method to add the class YAHOO.widget.DataTable.CLASS_SELECTED
      * for all TR elements on the page.
      *
      * @method _selectAllTrEls
      * @private
      */
      YAHOO.widget.DataTable.prototype._selectAllTrEls = function() {
         var selectedRowsEven = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_EVEN,"tr",this._elTbody);
         YAHOO.util.Dom.addClass(selectedRowsEven, YAHOO.widget.DataTable.CLASS_SELECTED);
         
         var selectedRowsOdd = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_ODD,"tr",this._elTbody);
         YAHOO.util.Dom.addClass(selectedRowsOdd, YAHOO.widget.DataTable.CLASS_SELECTED);
      };

      /** * Selects all rows. * * @method selectAllRows */

      YAHOO.widget.DataTable.prototype.selectAllRows = function() {
         // Remove all rows from tracker
         var tracker = this._aSelections || [];
         for(var j=tracker.length-1; j>-1; j--) {
            if(YAHOO.lang.isString(tracker[j])){
                 tracker.splice(j,1);
             }
         }
         // Update tracker
         this._aSelections = tracker;
         // Update UI
         this._selectAllTrEls();
         // Get all highlighted rows and make yahoo aware they are selected
          var selectedRowsEven = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"tr",this._elTbody);
          for (i=0;i<selectedRowsEven.length; i++){
          myDataTable.selectRow(i);
          console.log(myDataTable.getTrEl(i).cells[1].innerHTML);
          }
        
      };
       



      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail.yahoo.com


      No virus found in this incoming message.
      Checked by AVG Free Edition.
      Version: 7.5.503 / Virus Database: 269.15.14/1100 - Release Date: 30/10/2007 18:26
    Your message has been successfully submitted and would be delivered to recipients shortly.