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

Re: [ydn-javascript] Programmatically scroll datatable

Expand Messages
  • Satyam
    The DataTable has no direct way of doing that, actually, it wouldn t be a bad idea if you filed a Feature Request on SourceForge. In the meantime, I tried
    Message 1 of 2 , Mar 5, 2008
    • 0 Attachment
      The DataTable has no direct way of doing that, actually, it wouldn't be a
      bad idea if you filed a Feature Request on SourceForge. In the meantime, I
      tried this code:


      YAHOO.util.Event.on('showSelected','click',function() {
      var dt = YAHOO.example.ClientPagination.myDataTable; // shortcut
      var recId = dt.getSelectedRows(); // get the selected rows
      recId = recId[0]; // take the first record Id from the above array
      var rec = dt.getRecord(recId); // now, take the actual record
      console.log(rec.getData()); // just so see if it is the right one
      var recIndex = dt.getRecordSet().getRecordIndex(rec); // take the
      position of that record in the recordset
      var paginator = dt.get('paginator'); // get the paginator object
      var rpp = paginator.getRowsPerPage(); // read the rows per page value
      paginator.setPage(Math.floor(recIndex / rpp) + 1); // do the math and go
      there.


      });

      I placed a button on the table and when clicked the above code is run. I
      actually tried the code with a local copy of the client-side pagination
      example
      (http://developer.yahoo.com/yui/examples/datatable/dt_clientpagination.html)
      , that is where the reference to the DataTable comes from in the first line,
      the one I assign to the shortcut 'dt'. I jumped to a random page, selected
      a record in it, jumped elsewhere and then clicked the button and the page
      with the record selected showed up. It will only go to the first of the
      recordset selected, if more than one.

      Satyam



      ----- Original Message -----
      From: "out4colors" <jim.harlow@...>
      To: <ydn-javascript@yahoogroups.com>
      Sent: Tuesday, March 04, 2008 4:01 PM
      Subject: [ydn-javascript] Programmatically scroll datatable


      > Hi,
      >
      > I have YUI 2.5.0 which I am using with Firefox 2.0.0.12. I call
      > selectRow() on a datatable row which selects the row OK, but sometimes
      > this row is not visible. How can I scroll to that row programmatically?
      >
      > Thanks,
      > Jim
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      > --
      > No virus found in this incoming message.
      > Checked by AVG Free Edition.
      > Version: 7.5.516 / Virus Database: 269.21.4/1309 - Release Date:
      > 03/03/2008 18:50
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.