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

Initializing paginator to a different page

Expand Messages
  • Todd Wells
    I m using 2.6.0 and having trouble with a certain use case. Sometimes when I visit a page with a DataTable, my initial request isn t for the first page of data
    Message 1 of 16 , Nov 15, 2008
      I'm using 2.6.0 and having trouble with a certain use case. Sometimes when I visit a page with a DataTable, my initial request isn't for the first page of data -- for example, somebody's navigated away from the page and then returns, I'm tracking (via YUI history) what the last datatable query was, and my initial request for data is for the last query.  The query executes correctly, and the correct page of data is displayed in the table, but the paginator still indicates it's page 1.  If I try to manually set the startIndex or page of the paginator (even passing it the "silent" option), it still doesn't show the correct page, or this confuses the datatable which displays "no data".  I'm using dynamic data here, by the way.

      So, if, for example, I know my initial request is offset by 10 (e.g. page 2 in a 10-row page), how do I get the paginator to display that it is on page 2 rather than defaulting to page 1?  So I'm essentially trying to sync up where the Paginator thinks it is in the dataset with where it really is in the dataset.

      I've tried handling the payload returned and manually setting the oPayload.pagination.recordOffset based on metaFields returned by the server, but this doesn't do the correct thing, either -- I think the paginator thinks it's dataset is 20 and it should offset by 10, when in reality only 10 records were returned, they were just already offset.




    • MikeHatfield
      When you set oPayload.pagination.recordOffset, are you setting totalRecords also? Mike
      Message 2 of 16 , Nov 16, 2008
        When you set oPayload.pagination.recordOffset, are you setting totalRecords also?

        Mike
      • Todd Wells
        Yes I am also setting total records. I ve also tried just setState on the paginator, which according to the docs seems to be what I want (it claims to update
        Message 3 of 16 , Nov 16, 2008
          Yes I am also setting total records.  I've also tried just setState on the paginator, which according to the docs seems to be what I want (it claims to update the UI if needed) but nothing happens. 

          To summarize, if I know I'm currently displaying page 2 of records based on my initial query, how do I get the paginator to reflect that it's on page 2?


          On Sun, Nov 16, 2008 at 2:32 AM, MikeHatfield <mikehatfield@...> wrote:
          When you set oPayload.pagination.recordOffset, are you setting totalRecords also?

          Mike




          ------------------------------------

          Yahoo! Groups Links

          <*> To visit your group on the web, go to:
             http://groups.yahoo.com/group/ydn-javascript/

          <*> Your email settings:
             Individual Email | Traditional

          <*> To change settings online go to:
             http://groups.yahoo.com/group/ydn-javascript/join
             (Yahoo! ID required)

          <*> To change settings via email:
             mailto:ydn-javascript-digest@yahoogroups.com
             mailto:ydn-javascript-fullfeatured@yahoogroups.com

          <*> To unsubscribe from this group, send an email to:
             ydn-javascript-unsubscribe@yahoogroups.com

          <*> Your use of Yahoo! Groups is subject to:
             http://docs.yahoo.com/info/terms/


        • MikeHatfield
          I never really got the bottom of all the required interaction between the DataTable and Paginator in 2.6.0 when using History too. See my earlier post about
          Message 4 of 16 , Nov 16, 2008
            I never really got the bottom of all the required interaction between the DataTable and
            Paginator in 2.6.0 when using History too. See my earlier post about decoupling the
            widgets and controlling them manually - i.e. don't tell the DataTable about the Paginator
            at all, and call setState() in the renderEvent handler.

            The only other thing you could try is to override doBeforePaginatorChange and return
            false, i.e.:

            myDatatable.doBeforePaginatorChange = function(oPaginatorState)
            {
            return false;
            }


            I'd be really grateful if someone from the YUI team could put together a "definitive"
            DataTable, Paginator, History example which would remove this uncertainty and trial-and-
            error process.

            Cheers,
            Mike

            --- In ydn-javascript@yahoogroups.com, "Todd Wells" <ttopwells@...> wrote:
            >
            > Yes I am also setting total records. I've also tried just setState on the
            > paginator, which according to the docs seems to be what I want (it claims to
            > update the UI if needed) but nothing happens.
            >
            > To summarize, if I know I'm currently displaying page 2 of records based on
            > my initial query, how do I get the paginator to reflect that it's on page 2?
          • Todd Wells
            I m hoping someone more knowledgeable can respond to this... this is an important use case for my app, where I need the paginator to correctly reflect the
            Message 5 of 16 , Nov 17, 2008
              I'm hoping someone more knowledgeable can respond to this... this is an important use case for my app, where I need the paginator to correctly reflect the displayed page when the intial query is not for page one.

              On Sat, Nov 15, 2008 at 1:44 PM, Todd Wells <ttopwells@...> wrote:
              I'm using 2.6.0 and having trouble with a certain use case. Sometimes when I visit a page with a DataTable, my initial request isn't for the first page of data -- for example, somebody's navigated away from the page and then returns, I'm tracking (via YUI history) what the last datatable query was, and my initial request for data is for the last query.  The query executes correctly, and the correct page of data is displayed in the table, but the paginator still indicates it's page 1.  If I try to manually set the startIndex or page of the paginator (even passing it the "silent" option), it still doesn't show the correct page, or this confuses the datatable which displays "no data".  I'm using dynamic data here, by the way.

              So, if, for example, I know my initial request is offset by 10 (e.g. page 2 in a 10-row page), how do I get the paginator to display that it is on page 2 rather than defaulting to page 1?  So I'm essentially trying to sync up where the Paginator thinks it is in the dataset with where it really is in the dataset.

              I've tried handling the payload returned and manually setting the oPayload.pagination.recordOffset based on metaFields returned by the server, but this doesn't do the correct thing, either -- I think the paginator thinks it's dataset is 20 and it should offset by 10, when in reality only 10 records were returned, they were just already offset.





            • Lucas Smith
              ... Sometimes when ... first page ... and then ... query was, ... executes ... but the ... option), ... datatable which ... (e.g. page 2 ... is on page ...
              Message 6 of 16 , Nov 17, 2008
                --- In ydn-javascript@yahoogroups.com, "Todd Wells" <ttopwells@...> wrote:
                >
                > I'm hoping someone more knowledgeable can respond to this... this is an
                > important use case for my app, where I need the paginator to correctly
                > reflect the displayed page when the intial query is not for page one.
                >
                > On Sat, Nov 15, 2008 at 1:44 PM, Todd Wells <ttopwells@...> wrote:
                >
                > > I'm using 2.6.0 and having trouble with a certain use case.
                Sometimes when
                > > I visit a page with a DataTable, my initial request isn't for the
                first page
                > > of data -- for example, somebody's navigated away from the page
                and then
                > > returns, I'm tracking (via YUI history) what the last datatable
                query was,
                > > and my initial request for data is for the last query. The query
                executes
                > > correctly, and the correct page of data is displayed in the table,
                but the
                > > paginator still indicates it's page 1. If I try to manually set the
                > > startIndex or page of the paginator (even passing it the "silent"
                option),
                > > it still doesn't show the correct page, or this confuses the
                datatable which
                > > displays "no data". I'm using dynamic data here, by the way.
                > >
                > > So, if, for example, I know my initial request is offset by 10
                (e.g. page 2
                > > in a 10-row page), how do I get the paginator to display that it
                is on page
                > > 2 rather than defaulting to page 1? So I'm essentially trying to
                sync up
                > > where the Paginator thinks it is in the dataset with where it
                *really* is
                > > in the dataset.
                > >
                > > I've tried handling the payload returned and manually setting the
                > > oPayload.pagination.recordOffset based on metaFields returned by
                the server,
                > > but this doesn't do the correct thing, either -- I think the paginator
                > > thinks it's dataset is 20 and it should offset by 10, when in
                reality only
                > > 10 records were returned, they were just already offset.
                > >
                > >
                > >
                > >
                > >
                >


                Todd,

                Can you post (or post a link to a paste of) the code generating the
                DataTable? I can have a look and see what may be missing. Hopefully
                there isn't a regression in 2.6.

                Incidentally, have you looked at the initialPage config?

                Luke (author of Paginator)
              • Todd Wells
                In this case, I m just generating the initial request like this (in this case my intial offset is contrived, in a browser history situation I d be grabbing the
                Message 7 of 16 , Nov 17, 2008
                  In this case, I'm just generating the initial request like this (in this case my intial offset is contrived, in a browser history situation I'd be grabbing the initialRequest params from the history manager):

                      function getResultsTableConfig() {
                          var tableWidth;
                          var minWidth = 1024;
                          if (document.viewport.getWidth() > minWidth) {
                              tableWidth = document.viewport.getWidth();
                          } else {
                              tableWidth = minWidth;
                          }
                          return {
                              initialRequest:"format=json&offset=10&max=10&order=asc&sort=testCase" + "&filter=" + getCurrentFilter(),
                              width: tableWidth + "px",
                              renderLoopSize:10,
                              generateRequest: buildOutcomeQueryString,
                              paginator: getResultsPaginator(),
                              sortedBy: {key:"testCase", dir:YAHOO.widget.DataTable.CLASS_ASC},
                              dynamicData: true
                          };
                      }


                      function getResultsPaginator() {
                          return new YAHOO.widget.Paginator({
                              containers         : ['trDetailsPaging'],
                              pageLinks          : 5,
                              rowsPerPage        : 10,
                              rowsPerPageOptions : [10,15,20,30,50],
                              template       : "{FirstPageLink} {PageLinks} {LastPageLink}<br/>Show {RowsPerPageDropdown} per page",
                              pageLabelBuilder : function (page, paginator) {
                                  var recs = paginator.getPageRecords(page);
                                  return (recs[0] + 1) + ' - ' + (recs[1] + 1);
                              }
                          });
                      }

                  And then I was attempting to manipulate the paginator in the handleDataReturnPayload callback.  I didn't know about the initialPage option -- I just now tried that by adding a initialPage: 2 to the Paginator init above and it still displays as being on page 1.  Ideally I wouldn't want to have to calculate the initial page, I'd rather just tell the Paginator my offset and have it figure the page itself.



                  On Mon, Nov 17, 2008 at 7:10 AM, Lucas Smith <lsmith@...> wrote:
                  --- In ydn-javascript@yahoogroups.com, "Todd Wells" <ttopwells@...> wrote:
                  >
                  > I'm hoping someone more knowledgeable can respond to this... this is an
                  > important use case for my app, where I need the paginator to correctly
                  > reflect the displayed page when the intial query is not for page one.
                  >
                  > On Sat, Nov 15, 2008 at 1:44 PM, Todd Wells <ttopwells@...> wrote:
                  >
                  > > I'm using 2.6.0 and having trouble with a certain use case.
                  Sometimes when
                  > > I visit a page with a DataTable, my initial request isn't for the
                  first page
                  > > of data -- for example, somebody's navigated away from the page
                  and then
                  > > returns, I'm tracking (via YUI history) what the last datatable
                  query was,
                  > > and my initial request for data is for the last query.  The query
                  executes
                  > > correctly, and the correct page of data is displayed in the table,
                  but the
                  > > paginator still indicates it's page 1.  If I try to manually set the
                  > > startIndex or page of the paginator (even passing it the "silent"
                  option),
                  > > it still doesn't show the correct page, or this confuses the
                  datatable which
                  > > displays "no data".  I'm using dynamic data here, by the way.
                  > >
                  > > So, if, for example, I know my initial request is offset by 10
                  (e.g. page 2
                  > > in a 10-row page), how do I get the paginator to display that it
                  is on page
                  > > 2 rather than defaulting to page 1?  So I'm essentially trying to
                  sync up
                  > > where the Paginator thinks it is in the dataset with where it
                  *really* is
                  > > in the dataset.
                  > >
                  > > I've tried handling the payload returned and manually setting the
                  > > oPayload.pagination.recordOffset based on metaFields returned by
                  the server,
                  > > but this doesn't do the correct thing, either -- I think the paginator
                  > > thinks it's dataset is 20 and it should offset by 10, when in
                  reality only
                  > > 10 records were returned, they were just already offset.
                  > >
                  > >
                  > >
                  > >
                  > >
                  >


                  Todd,

                  Can you post (or post a link to a paste of) the code generating the
                  DataTable?  I can have a look and see what may be missing.  Hopefully
                  there isn't a regression in 2.6.

                  Incidentally, have you looked at the initialPage config?

                  Luke (author of Paginator)


                  ------------------------------------

                  Yahoo! Groups Links

                  <*> To visit your group on the web, go to:
                     http://groups.yahoo.com/group/ydn-javascript/

                  <*> Your email settings:
                     Individual Email | Traditional

                  <*> To change settings online go to:
                     http://groups.yahoo.com/group/ydn-javascript/join
                     (Yahoo! ID required)

                  <*> To change settings via email:
                     mailto:ydn-javascript-digest@yahoogroups.com
                     mailto:ydn-javascript-fullfeatured@yahoogroups.com

                  <*> To unsubscribe from this group, send an email to:
                     ydn-javascript-unsubscribe@yahoogroups.com

                  <*> Your use of Yahoo! Groups is subject to:
                     http://docs.yahoo.com/info/terms/


                • German Escallon
                  ... Hash: SHA1 I have done this in the past.. here s a code snippet. let me know if you have any questions. //datatable column definition var columnDef = [ {
                  Message 8 of 16 , Nov 17, 2008
                    -----BEGIN PGP SIGNED MESSAGE-----
                    Hash: SHA1

                    I have done this in the past.. here's a code snippet. let me know if
                    you have any questions.

                    //datatable column definition
                    var columnDef =
                    [

                    {

                    key: "checkbox",
                    label:'<input
                    onclick="ToggleAllProfiles(this)" id="allProfilesCheckbox"
                    type="checkbox" />',

                    formatter:
                    function(elCell, oRecord, oColumn, oData)
                    {
                    elCell.innerHTML =
                    '<input id="checkbox_' +
                    oRecord.getData("slot") + '" type="checkbox" />';
                    }
                    },

                    {
                    /**************
                    in my example, slot is the index of the record (0 - n). A better way
                    of doing this, if you don't have a column with the index of the
                    record, is to use the recordset instance of your datatable.
                    ***************/
                    key: "slot",
                    label:"<b>Slot</b>",
                    resizeable: true,
                    sortable: true,

                    formatter:
                    function(elCell, oRecord, oColumn, oData)
                    {
                    elCell.innerHTML = oData;
                    }
                    },
                    ....



                    function
                    ToggleAllProfiles
                    (
                    checkBoxObj
                    )
                    {
                    var check = checkBoxObj.checked; //boolean
                    for(var i=0; i<NUM_RECORDS; i++)
                    {
                    var checkbox = document.getElementById("checkbox_" + i);
                    /*****
                    Again, you can use the recordSet object of your datatble to get the
                    index of your record.
                    ******/
                    if(checkbox!==null)
                    {
                    checkbox.checked = check;
                    }
                    }
                    return false;
                    }

                    Todd Wells wrote:
                    >
                    > In this case, I'm just generating the initial request like this (in
                    > this case my intial offset is contrived, in a browser history
                    > situation I'd be grabbing the initialRequest params from the
                    > history manager):
                    >
                    > function getResultsTableConfig() { var tableWidth; var minWidth =
                    > 1024; if (document.viewport.getWidth() > minWidth) { tableWidth =
                    > document.viewport.getWidth(); } else { tableWidth = minWidth; }
                    > return {
                    >
                    > initialRequest:"format=json&*offset=10*&max=10&order=asc&sort=testCase"
                    > + "&filter=" + getCurrentFilter(), width: tableWidth + "px",
                    > renderLoopSize:10, generateRequest: buildOutcomeQueryString,
                    > paginator: getResultsPaginator(), sortedBy: {key:"testCase",
                    > dir:YAHOO.widget.DataTable.CLASS_ASC}, dynamicData: true }; }
                    >
                    >
                    > function getResultsPaginator() { return new
                    > YAHOO.widget.Paginator({ containers : ['trDetailsPaging'],
                    > pageLinks : 5, rowsPerPage : 10, rowsPerPageOptions
                    > : [10,15,20,30,50], template : "{FirstPageLink} {PageLinks}
                    > {LastPageLink}<br/>Show {RowsPerPageDropdown} per page",
                    > pageLabelBuilder : function (page, paginator) { var recs =
                    > paginator.getPageRecords(page); return (recs[0] + 1) + ' - ' +
                    > (recs[1] + 1); } }); }
                    >
                    > And then I was attempting to manipulate the paginator in the
                    > handleDataReturnPayload callback. I didn't know about the
                    > initialPage option -- I just now tried that by adding a
                    > initialPage: 2 to the Paginator init above and it still displays as
                    > being on page 1. Ideally I wouldn't want to have to calculate the
                    > initial page, I'd rather just tell the Paginator my offset and have
                    > it figure the page itself.
                    >
                    >
                    >
                    > On Mon, Nov 17, 2008 at 7:10 AM, Lucas Smith <lsmith@...
                    > <mailto:lsmith@...>> wrote:
                    >
                    > --- In ydn-javascript@yahoogroups.com
                    > <mailto:ydn-javascript@yahoogroups.com>, "Todd Wells"
                    > <ttopwells@...> wrote:
                    >>
                    >> I'm hoping someone more knowledgeable can respond to this...
                    > this is an
                    >> important use case for my app, where I need the paginator to
                    > correctly
                    >> reflect the displayed page when the intial query is not for
                    > page one.
                    >>
                    >> On Sat, Nov 15, 2008 at 1:44 PM, Todd Wells <ttopwells@...>
                    >> wrote:
                    >>
                    >>> I'm using 2.6.0 and having trouble with a certain use case.
                    > Sometimes when
                    >>> I visit a page with a DataTable, my initial request isn't
                    > for the first page
                    >>> of data -- for example, somebody's navigated away from the page
                    >>>
                    > and then
                    >>> returns, I'm tracking (via YUI history) what the last datatable
                    >>>
                    > query was,
                    >>> and my initial request for data is for the last query. The
                    > query executes
                    >>> correctly, and the correct page of data is displayed in the
                    > table, but the
                    >>> paginator still indicates it's page 1. If I try to manually
                    > set the
                    >>> startIndex or page of the paginator (even passing it the
                    > "silent" option),
                    >>> it still doesn't show the correct page, or this confuses the
                    > datatable which
                    >>> displays "no data". I'm using dynamic data here, by the way.
                    >>>
                    >>> So, if, for example, I know my initial request is offset by 10
                    > (e.g. page 2
                    >>> in a 10-row page), how do I get the paginator to display that
                    >>> it
                    > is on page
                    >>> 2 rather than defaulting to page 1? So I'm essentially
                    > trying to sync up
                    >>> where the Paginator thinks it is in the dataset with where it
                    > *really* is
                    >>> in the dataset.
                    >>>
                    >>> I've tried handling the payload returned and manually
                    > setting the
                    >>> oPayload.pagination.recordOffset based on metaFields returned
                    >>> by
                    > the server,
                    >>> but this doesn't do the correct thing, either -- I think the
                    > paginator
                    >>> thinks it's dataset is 20 and it should offset by 10, when in
                    > reality only
                    >>> 10 records were returned, they were just already offset.
                    >>>
                    >>>
                    >>>
                    >>>
                    >>>
                    >>
                    >
                    >
                    > Todd,
                    >
                    > Can you post (or post a link to a paste of) the code generating the
                    > DataTable? I can have a look and see what may be missing.
                    > Hopefully there isn't a regression in 2.6.
                    >
                    > Incidentally, have you looked at the initialPage config?
                    >
                    > Luke (author of Paginator)
                    >
                    >
                    > ------------------------------------
                    >
                    > Yahoo! Groups Links
                    >
                    >
                    > required)
                    >
                    > mailto:ydn-javascript-fullfeatured@yahoogroups.com
                    > <mailto:ydn-javascript-fullfeatured@yahoogroups.com>
                    >
                    >
                    >
                    >
                    >
                    > ______________________________________________________________________
                    > This email has been scanned by the MessageLabs Email Security
                    > System. For more information please visit
                    > http://www.messagelabs.com/email
                    > ______________________________________________________________________
                    > <!-- #ygrp-mkp{ border: 1px solid #d8d8d8; font-family: Arial;
                    > margin: 14px 0px; padding: 0px 14px; } #ygrp-mkp hr{ border: 1px
                    > solid #d8d8d8; } #ygrp-mkp #hd{ color: #628c2a; font-size: 85%;
                    > font-weight: bold; line-height: 122%; margin: 10px 0px; } #ygrp-mkp
                    > #ads{ margin-bottom: 10px; } #ygrp-mkp .ad{ padding: 0 0; }
                    > #ygrp-mkp .ad a{ color: #0000ff; text-decoration: none; } --> <!--
                    > #ygrp-sponsor #ygrp-lc{ font-family: Arial; } #ygrp-sponsor
                    > #ygrp-lc #hd{ margin: 10px 0px; font-weight: bold; font-size: 78%;
                    > line-height: 122%; } #ygrp-sponsor #ygrp-lc .ad{ margin-bottom:
                    > 10px; padding: 0 0; } --> <!-- #ygrp-mlmsg {font-size:13px;
                    > font-family:
                    > arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}
                    > #ygrp-mlmsg table {font-size:inherit;font:100%;} #ygrp-mlmsg
                    > select, input, textarea {font:99%
                    > arial,helvetica,clean,sans-serif;} #ygrp-mlmsg pre, code {font:115%
                    > monospace;*font-size:100%;} #ygrp-mlmsg * {line-height:1.22em;}
                    > #ygrp-text{ font-family: Georgia; } #ygrp-text p{ margin: 0 0 1em
                    > 0; } #ygrp-tpmsgs{ font-family: Arial; clear: both; } #ygrp-vitnav{
                    > padding-top: 10px; font-family: Verdana; font-size: 77%; margin: 0;
                    > } #ygrp-vitnav a{ padding: 0 1px; } #ygrp-actbar{ clear: both;
                    > margin: 25px 0; white-space:nowrap; color: #666; text-align: right;
                    > } #ygrp-actbar .left{ float: left; white-space:nowrap; }
                    > .bld{font-weight:bold;} #ygrp-grft{ font-family: Verdana;
                    > font-size: 77%; padding: 15px 0; } #ygrp-ft{ font-family: verdana;
                    > font-size: 77%; border-top: 1px solid #666; padding: 5px 0; }
                    > #ygrp-mlmsg #logo{ padding-bottom: 10px; } #ygrp-reco {
                    > margin-bottom: 20px; padding: 0px; } #ygrp-reco #reco-head {
                    > font-weight: bold; color: #ff7900; } #reco-grpname{ font-weight:
                    > bold; margin-top: 10px; } #reco-category{ font-size: 77%; }
                    > #reco-desc{ font-size: 77%; } #ygrp-vital{ background-color:
                    > #e0ecee; margin-bottom: 20px; padding: 2px 0 8px 8px; } #ygrp-vital
                    > #vithd{ font-size: 77%; font-family: Verdana; font-weight: bold;
                    > color: #333; text-transform: uppercase; } #ygrp-vital ul{ padding:
                    > 0; margin: 2px 0; } #ygrp-vital ul li{ list-style-type: none;
                    > clear: both; border: 1px solid #e0ecee; } #ygrp-vital ul li .ct{
                    > font-weight: bold; color: #ff7900; float: right; width: 2em;
                    > text-align:right; padding-right: .5em; } #ygrp-vital ul li .cat{
                    > font-weight: bold; } #ygrp-vital a{ text-decoration: none; }
                    > #ygrp-vital a:hover{ text-decoration: underline; } #ygrp-sponsor
                    > #hd{ color: #999; font-size: 77%; } #ygrp-sponsor #ov{ padding: 6px
                    > 13px; background-color: #e0ecee; margin-bottom: 20px; }
                    > #ygrp-sponsor #ov ul{ padding: 0 0 0 8px; margin: 0; }
                    > #ygrp-sponsor #ov li{ list-style-type: square; padding: 6px 0;
                    > font-size: 77%; } #ygrp-sponsor #ov li a{ text-decoration: none;
                    > font-size: 130%; } #ygrp-sponsor #nc{ background-color: #eee;
                    > margin-bottom: 20px; padding: 0 8px; } #ygrp-sponsor .ad{ padding:
                    > 8px 0; } #ygrp-sponsor .ad #hd1{ font-family: Arial; font-weight:
                    > bold; color: #628c2a; font-size: 100%; line-height: 122%; }
                    > #ygrp-sponsor .ad a{ text-decoration: none; } #ygrp-sponsor .ad
                    > a:hover{ text-decoration: underline; } #ygrp-sponsor .ad p{ margin:
                    > 0; } o{font-size: 0; } .MsoNormal{ margin: 0 0 0 0; } #ygrp-text
                    > tt{ font-size: 120%; } blockquote{margin: 0 0 0 4px;}
                    > .replbq{margin:4} -->
                    -----BEGIN PGP SIGNATURE-----
                    Version: GnuPG v2.0.4-svn0 (GNU/Linux)
                    Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

                    iD8DBQFJIaJTkt7KGge+MvERAsqvAJ9D9hsevArBUApUfuJDTVdtQXFZeACgrmng
                    Q4GMfdnTHMGaXZJYInJCfBM=
                    =jz6t
                    -----END PGP SIGNATURE-----


                    ______________________________________________________________________
                    This email has been scanned by the MessageLabs Email Security System.
                    For more information please visit http://www.messagelabs.com/email
                    ______________________________________________________________________
                  • German Escallon
                    ... Hash: SHA1 Sorry, it seems like I responded to the wrong thread. ... __________________________________________________________ This email has been scanned
                    Message 9 of 16 , Nov 17, 2008
                      -----BEGIN PGP SIGNED MESSAGE-----
                      Hash: SHA1

                      Sorry, it seems like I responded to the wrong thread.

                      German Escallon wrote:
                      >
                      > I have done this in the past.. here's a code snippet. let me know
                      > if you have any questions.
                      >
                      > //datatable column definition var columnDef = [
                      >
                      > {
                      >
                      > key: "checkbox", label:'<input onclick="ToggleAllProfiles(this)"
                      > id="allProfilesCheckbox" type="checkbox" />',
                      >
                      > formatter: function(elCell, oRecord, oColumn, oData) {
                      > elCell.innerHTML = '<input id="checkbox_' + oRecord.getData("slot")
                      > + '" type="checkbox" />'; } },
                      >
                      > { /************** in my example, slot is the index of the record (0
                      > - n). A better way of doing this, if you don't have a column with
                      > the index of the record, is to use the recordset instance of your
                      > datatable. ***************/ key: "slot", label:"<b>Slot</b>",
                      > resizeable: true, sortable: true,
                      >
                      > formatter: function(elCell, oRecord, oColumn, oData) {
                      > elCell.innerHTML = oData; } }, ....
                      >
                      > function ToggleAllProfiles ( checkBoxObj ) { var check =
                      > checkBoxObj.checked; //boolean for(var i=0; i<NUM_RECORDS; i++) {
                      > var checkbox = document.getElementById("checkbox_" + i); /*****
                      > Again, you can use the recordSet object of your datatble to get the
                      > index of your record. ******/ if(checkbox!==null) {
                      > checkbox.checked = check; } } return false; }
                      >
                      > Todd Wells wrote:
                      >
                      >> In this case, I'm just generating the initial request like this
                      >> (in this case my intial offset is contrived, in a browser history
                      >> situation I'd be grabbing the initialRequest params from the
                      >> history manager):
                      >
                      >> function getResultsTableConfig() { var tableWidth; var minWidth =
                      >> 1024; if (document.viewport.getWidth() > minWidth) { tableWidth
                      >> = document.viewport.getWidth(); } else { tableWidth = minWidth; }
                      >> return {
                      >
                      >
                      > initialRequest:"format=json&*offset=10*&max=10&order=asc&sort=testCase"
                      >
                      >> + "&filter=" + getCurrentFilter(), width: tableWidth + "px",
                      >> renderLoopSize:10, generateRequest: buildOutcomeQueryString,
                      >> paginator: getResultsPaginator(), sortedBy: {key:"testCase",
                      >> dir:YAHOO.widget.DataTable.CLASS_ASC}, dynamicData: true }; }
                      >
                      >
                      >> function getResultsPaginator() { return new
                      >> YAHOO.widget.Paginator({ containers : ['trDetailsPaging'],
                      >> pageLinks : 5, rowsPerPage : 10, rowsPerPageOptions :
                      >> [10,15,20,30,50], template : "{FirstPageLink} {PageLinks}
                      >> {LastPageLink}<br/>Show {RowsPerPageDropdown} per page",
                      >> pageLabelBuilder : function (page, paginator) { var recs =
                      >> paginator.getPageRecords(page); return (recs[0] + 1) + ' - ' +
                      >> (recs[1] + 1); } }); }
                      >
                      >> And then I was attempting to manipulate the paginator in the
                      >> handleDataReturnPayload callback. I didn't know about the
                      >> initialPage option -- I just now tried that by adding a
                      >> initialPage: 2 to the Paginator init above and it still displays
                      >> as being on page 1. Ideally I wouldn't want to have to calculate
                      >> the initial page, I'd rather just tell the Paginator my offset
                      >> and have it figure the page itself.
                      >
                      >
                      >
                      >> On Mon, Nov 17, 2008 at 7:10 AM, Lucas Smith
                      >> <lsmith@...
                      > <mailto:lsmith%40yahoo-inc.com>
                      >> <mailto:lsmith@... <mailto:lsmith%40yahoo-inc.com>>>
                      >> wrote:
                      >
                      >> --- In ydn-javascript@yahoogroups.com
                      > <mailto:ydn-javascript%40yahoogroups.com>
                      >> <mailto:ydn-javascript@yahoogroups.com
                      > <mailto:ydn-javascript%40yahoogroups.com>>, "Todd Wells"
                      >> <ttopwells@...> wrote:
                      >>>
                      >>> I'm hoping someone more knowledgeable can respond to this...
                      >> this is an
                      >>> important use case for my app, where I need the paginator to
                      >> correctly
                      >>> reflect the displayed page when the intial query is not for
                      >> page one.
                      >>>
                      >>> On Sat, Nov 15, 2008 at 1:44 PM, Todd Wells <ttopwells@...>
                      >>> wrote:
                      >>>
                      >>>> I'm using 2.6.0 and having trouble with a certain use case.
                      >> Sometimes when
                      >>>> I visit a page with a DataTable, my initial request isn't
                      >> for the first page
                      >>>> of data -- for example, somebody's navigated away from the
                      >>>> page
                      >>>>
                      >> and then
                      >>>> returns, I'm tracking (via YUI history) what the last
                      >>>> datatable
                      >>>>
                      >> query was,
                      >>>> and my initial request for data is for the last query. The
                      >> query executes
                      >>>> correctly, and the correct page of data is displayed in the
                      >> table, but the
                      >>>> paginator still indicates it's page 1. If I try to manually
                      >> set the
                      >>>> startIndex or page of the paginator (even passing it the
                      >> "silent" option),
                      >>>> it still doesn't show the correct page, or this confuses the
                      >> datatable which
                      >>>> displays "no data". I'm using dynamic data here, by the way.
                      >>>>
                      >>>> So, if, for example, I know my initial request is offset by
                      >>>> 10
                      >> (e.g. page 2
                      >>>> in a 10-row page), how do I get the paginator to display that
                      >>>> it
                      >> is on page
                      >>>> 2 rather than defaulting to page 1? So I'm essentially
                      >> trying to sync up
                      >>>> where the Paginator thinks it is in the dataset with where it
                      >>>>
                      >> *really* is
                      >>>> in the dataset.
                      >>>>
                      >>>> I've tried handling the payload returned and manually
                      >> setting the
                      >>>> oPayload.pagination.recordOffset based on metaFields returned
                      >>>> by
                      >> the server,
                      >>>> but this doesn't do the correct thing, either -- I think the
                      >> paginator
                      >>>> thinks it's dataset is 20 and it should offset by 10, when in
                      >>>>
                      >> reality only
                      >>>> 10 records were returned, they were just already offset.
                      >>>>
                      >>>>
                      >>>>
                      >>>>
                      >>>>
                      >>>
                      >
                      >
                      >> Todd,
                      >
                      >> Can you post (or post a link to a paste of) the code generating
                      >> the DataTable? I can have a look and see what may be missing.
                      >> Hopefully there isn't a regression in 2.6.
                      >
                      >> Incidentally, have you looked at the initialPage config?
                      >
                      >> Luke (author of Paginator)
                      >
                      >
                      >> ------------------------------------
                      >
                      >> Yahoo! Groups Links
                      >
                      >
                      >> required)
                      >
                      >> mailto:ydn-javascript-fullfeatured@yahoogroups.com
                      > <mailto:ydn-javascript-fullfeatured%40yahoogroups.com>
                      >> <mailto:ydn-javascript-fullfeatured@yahoogroups.com
                      > <mailto:ydn-javascript-fullfeatured%40yahoogroups.com>>
                      >
                      >
                      >
                      >
                      >
                      >> __________________________________________________________ This
                      >> email has been scanned by the MessageLabs Email Security System.
                      >> For more information please visit
                      >> http://www.messagelabs.com/email
                      >> <http://www.messagelabs.com/email>
                      >> __________________________________________________________ <!--
                      >> #ygrp-mkp{ border: 1px solid #d8d8d8; font-family: Arial; margin:
                      >> 14px 0px; padding: 0px 14px; } #ygrp-mkp hr{ border: 1px solid
                      >> #d8d8d8; } #ygrp-mkp #hd{ color: #628c2a; font-size: 85%;
                      >> font-weight: bold; line-height: 122%; margin: 10px 0px; }
                      >> #ygrp-mkp #ads{ margin-bottom: 10px; } #ygrp-mkp .ad{ padding: 0
                      >> 0; } #ygrp-mkp .ad a{ color: #0000ff; text-decoration: none; }
                      >> --> <!-- #ygrp-sponsor #ygrp-lc{ font-family: Arial; }
                      >> #ygrp-sponsor #ygrp-lc #hd{ margin: 10px 0px; font-weight: bold;
                      >> font-size: 78%; line-height: 122%; } #ygrp-sponsor #ygrp-lc .ad{
                      >> margin-bottom: 10px; padding: 0 0; } --> <!-- #ygrp-mlmsg
                      >> {font-size:13px; font-family:
                      >> arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}
                      >> #ygrp-mlmsg table {font-size:inherit;font:100%;} #ygrp-mlmsg
                      >> select, input, textarea {font:99%
                      >> arial,helvetica,clean,sans-serif;} #ygrp-mlmsg pre, code
                      >> {font:115% monospace;*font-size:100%;} #ygrp-mlmsg *
                      >> {line-height:1.22em;} #ygrp-text{ font-family: Georgia; }
                      >> #ygrp-text p{ margin: 0 0 1em 0; } #ygrp-tpmsgs{ font-family:
                      >> Arial; clear: both; } #ygrp-vitnav{ padding-top: 10px;
                      >> font-family: Verdana; font-size: 77%; margin: 0; } #ygrp-vitnav
                      >> a{ padding: 0 1px; } #ygrp-actbar{ clear: both; margin: 25px 0;
                      >> white-space:nowrap; color: #666; text-align: right; }
                      >> #ygrp-actbar .left{ float: left; white-space:nowrap; }
                      >> .bld{font-weight:bold;} #ygrp-grft{ font-family: Verdana;
                      >> font-size: 77%; padding: 15px 0; } #ygrp-ft{ font-family:
                      >> verdana; font-size: 77%; border-top: 1px solid #666; padding: 5px
                      >> 0; } #ygrp-mlmsg #logo{ padding-bottom: 10px; } #ygrp-reco {
                      >> margin-bottom: 20px; padding: 0px; } #ygrp-reco #reco-head {
                      >> font-weight: bold; color: #ff7900; } #reco-grpname{ font-weight:
                      >> bold; margin-top: 10px; } #reco-category{ font-size: 77%; }
                      >> #reco-desc{ font-size: 77%; } #ygrp-vital{ background-color:
                      >> #e0ecee; margin-bottom: 20px; padding: 2px 0 8px 8px; }
                      >> #ygrp-vital #vithd{ font-size: 77%; font-family: Verdana;
                      >> font-weight: bold; color: #333; text-transform: uppercase; }
                      >> #ygrp-vital ul{ padding: 0; margin: 2px 0; } #ygrp-vital ul li{
                      >> list-style-type: none; clear: both; border: 1px solid #e0ecee; }
                      >> #ygrp-vital ul li .ct{ font-weight: bold; color: #ff7900; float:
                      >> right; width: 2em; text-align:right; padding-right: .5em; }
                      >> #ygrp-vital ul li .cat{ font-weight: bold; } #ygrp-vital a{
                      >> text-decoration: none; } #ygrp-vital a:hover{ text-decoration:
                      >> underline; } #ygrp-sponsor #hd{ color: #999; font-size: 77%; }
                      >> #ygrp-sponsor #ov{ padding: 6px 13px; background-color: #e0ecee;
                      >> margin-bottom: 20px; } #ygrp-sponsor #ov ul{ padding: 0 0 0 8px;
                      >> margin: 0; } #ygrp-sponsor #ov li{ list-style-type: square;
                      >> padding: 6px 0; font-size: 77%; } #ygrp-sponsor #ov li a{
                      >> text-decoration: none; font-size: 130%; } #ygrp-sponsor #nc{
                      >> background-color: #eee; margin-bottom: 20px; padding: 0 8px; }
                      >> #ygrp-sponsor .ad{ padding: 8px 0; } #ygrp-sponsor .ad #hd1{
                      >> font-family: Arial; font-weight: bold; color: #628c2a; font-size:
                      >> 100%; line-height: 122%; } #ygrp-sponsor .ad a{ text-decoration:
                      >> none; } #ygrp-sponsor .ad a:hover{ text-decoration: underline; }
                      >> #ygrp-sponsor .ad p{ margin: 0; } o{font-size: 0; } .MsoNormal{
                      >> margin: 0 0 0 0; } #ygrp-text tt{ font-size: 120%; }
                      >> blockquote{margin: 0 0 0 4px;} .replbq{margin:4} -->

                      __________________________________________________________
                      This email has been scanned by the MessageLabs Email Security System.
                      For more information please visit http://www.messagelabs.com/email
                      <http://www.messagelabs.com/email>
                      __________________________________________________________


                      ______________________________________________________________________
                      This email has been scanned by the MessageLabs Email Security System.
                      For more information please visit http://www.messagelabs.com/email
                      ______________________________________________________________________
                      <!-- #ygrp-mkp{ border: 1px solid #d8d8d8; font-family: Arial;
                      margin: 14px 0px; padding: 0px 14px; } #ygrp-mkp hr{ border: 1px
                      solid #d8d8d8; } #ygrp-mkp #hd{ color: #628c2a; font-size: 85%;
                      font-weight: bold; line-height: 122%; margin: 10px 0px; } #ygrp-mkp
                      #ads{ margin-bottom: 10px; } #ygrp-mkp .ad{ padding: 0 0; }
                      #ygrp-mkp .ad a{ color: #0000ff; text-decoration: none; } --> <!--
                      #ygrp-sponsor #ygrp-lc{ font-family: Arial; } #ygrp-sponsor #ygrp-lc
                      #hd{ margin: 10px 0px; font-weight: bold; font-size: 78%;
                      line-height: 122%; } #ygrp-sponsor #ygrp-lc .ad{ margin-bottom:
                      10px; padding: 0 0; } --> <!-- #ygrp-mlmsg {font-size:13px;
                      font-family:
                      arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}
                      #ygrp-mlmsg table {font-size:inherit;font:100%;} #ygrp-mlmsg select,
                      input, textarea {font:99% arial,helvetica,clean,sans-serif;}
                      #ygrp-mlmsg pre, code {font:115% monospace;*font-size:100%;}
                      #ygrp-mlmsg * {line-height:1.22em;} #ygrp-text{ font-family:
                      Georgia; } #ygrp-text p{ margin: 0 0 1em 0; } #ygrp-tpmsgs{
                      font-family: Arial; clear: both; } #ygrp-vitnav{ padding-top: 10px;
                      font-family: Verdana; font-size: 77%; margin: 0; } #ygrp-vitnav a{
                      padding: 0 1px; } #ygrp-actbar{ clear: both; margin: 25px 0;
                      white-space:nowrap; color: #666; text-align: right; } #ygrp-actbar
                      .left{ float: left; white-space:nowrap; } .bld{font-weight:bold;}
                      #ygrp-grft{ font-family: Verdana; font-size: 77%; padding: 15px 0; }
                      #ygrp-ft{ font-family: verdana; font-size: 77%; border-top: 1px
                      solid #666; padding: 5px 0; } #ygrp-mlmsg #logo{ padding-bottom:
                      10px; } #ygrp-reco { margin-bottom: 20px; padding: 0px; } #ygrp-reco
                      #reco-head { font-weight: bold; color: #ff7900; } #reco-grpname{
                      font-weight: bold; margin-top: 10px; } #reco-category{ font-size:
                      77%; } #reco-desc{ font-size: 77%; } #ygrp-vital{ background-color:
                      #e0ecee; margin-bottom: 20px; padding: 2px 0 8px 8px; } #ygrp-vital
                      #vithd{ font-size: 77%; font-family: Verdana; font-weight: bold;
                      color: #333; text-transform: uppercase; } #ygrp-vital ul{ padding:
                      0; margin: 2px 0; } #ygrp-vital ul li{ list-style-type: none; clear:
                      both; border: 1px solid #e0ecee; } #ygrp-vital ul li .ct{
                      font-weight: bold; color: #ff7900; float: right; width: 2em;
                      text-align:right; padding-right: .5em; } #ygrp-vital ul li .cat{
                      font-weight: bold; } #ygrp-vital a{ text-decoration: none; }
                      #ygrp-vital a:hover{ text-decoration: underline; } #ygrp-sponsor
                      #hd{ color: #999; font-size: 77%; } #ygrp-sponsor #ov{ padding: 6px
                      13px; background-color: #e0ecee; margin-bottom: 20px; }
                      #ygrp-sponsor #ov ul{ padding: 0 0 0 8px; margin: 0; } #ygrp-sponsor
                      #ov li{ list-style-type: square; padding: 6px 0; font-size: 77%; }
                      #ygrp-sponsor #ov li a{ text-decoration: none; font-size: 130%; }
                      #ygrp-sponsor #nc{ background-color: #eee; margin-bottom: 20px;
                      padding: 0 8px; } #ygrp-sponsor .ad{ padding: 8px 0; } #ygrp-sponsor
                      .ad #hd1{ font-family: Arial; font-weight: bold; color: #628c2a;
                      font-size: 100%; line-height: 122%; } #ygrp-sponsor .ad a{
                      text-decoration: none; } #ygrp-sponsor .ad a:hover{ text-decoration:
                      underline; } #ygrp-sponsor .ad p{ margin: 0; } o{font-size: 0; }
                      .MsoNormal{ margin: 0 0 0 0; } #ygrp-text tt{ font-size: 120%; }
                      blockquote{margin: 0 0 0 4px;} .replbq{margin:4} -->
                      -----BEGIN PGP SIGNATURE-----
                      Version: GnuPG v2.0.4-svn0 (GNU/Linux)
                      Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

                      iD8DBQFJIaSVkt7KGge+MvERAkkwAKCNNuLu+Q0esL7NPajAQtcA4Ap1+gCgsJ9f
                      GyJWhTrOfjWBbUUecCloHOE=
                      =xsN+
                      -----END PGP SIGNATURE-----


                      ______________________________________________________________________
                      This email has been scanned by the MessageLabs Email Security System.
                      For more information please visit http://www.messagelabs.com/email
                      ______________________________________________________________________
                    • Todd Wells
                      I think maybe this is responding to a different message? As far as I can tell this doesn t apply to what I m trying to do, which is have the paginator display
                      Message 10 of 16 , Nov 17, 2008
                        I think maybe this is responding to a different message? As far as I can tell this doesn't apply to what I'm trying to do, which is have the paginator display the correct page.

                        On Mon, Nov 17, 2008 at 9:04 AM, German Escallon <germane@...> wrote:
                        -----BEGIN PGP SIGNED MESSAGE-----
                        Hash: SHA1

                        I have done this in the past..  here's a code snippet.  let me know if
                        you have any questions.

                                    //datatable column definition
                                      var columnDef =
                                         [

                                            {

                                               key: "checkbox",
                                               label:'<input
                        onclick="ToggleAllProfiles(this)" id="allProfilesCheckbox"
                        type="checkbox" />',

                                               formatter:
                                                  function(elCell, oRecord, oColumn, oData)
                                                  {
                                                     elCell.innerHTML =
                                                        '<input id="checkbox_' +
                        oRecord.getData("slot") + '" type="checkbox" />';
                                                  }
                                            },

                                            {
                        /**************
                         in my example, slot is the index of the record (0 - n). A better way
                        of doing this, if you don't have a column with the index of the
                        record, is to use the recordset instance of your datatable.
                        ***************/
                                               key: "slot",
                                               label:"<b>Slot</b>",
                                               resizeable: true,
                                               sortable: true,

                                               formatter:
                                                  function(elCell, oRecord, oColumn, oData)
                                                  {
                                                     elCell.innerHTML = oData;
                                                  }
                                            },
                        ....



                        function
                        ToggleAllProfiles
                          (
                          checkBoxObj
                          )
                          {
                             var check = checkBoxObj.checked; //boolean
                             for(var i=0; i<NUM_RECORDS; i++)
                             {
                                var checkbox = document.getElementById("checkbox_" + i);
                        /*****
                         Again, you can use the recordSet object of your datatble to get the
                        index of your record.
                        ******/
                                if(checkbox!==null)
                                {
                                   checkbox.checked = check;
                                }
                             }
                             return false;
                          }

                        Todd Wells wrote:
                        >
                        > In this case, I'm just generating the initial request like this (in
                        >  this case my intial offset is contrived, in a browser history
                        > situation I'd be grabbing the initialRequest params from the
                        > history manager):
                        >
                        > function getResultsTableConfig() { var tableWidth; var minWidth =
                        > 1024; if (document.viewport.getWidth() > minWidth) { tableWidth =
                        > document.viewport.getWidth(); } else { tableWidth = minWidth; }
                        > return {
                        >
                        > initialRequest:"format=json&*offset=10*&max=10&order=asc&sort=testCase"
                        >  + "&filter=" + getCurrentFilter(), width: tableWidth + "px",
                        > renderLoopSize:10, generateRequest: buildOutcomeQueryString,
                        > paginator: getResultsPaginator(), sortedBy: {key:"testCase",
                        > dir:YAHOO.widget.DataTable.CLASS_ASC}, dynamicData: true }; }
                        >
                        >
                        > function getResultsPaginator() { return new
                        > YAHOO.widget.Paginator({ containers         : ['trDetailsPaging'],
                        > pageLinks          : 5, rowsPerPage        : 10, rowsPerPageOptions
                        > : [10,15,20,30,50], template       : "{FirstPageLink} {PageLinks}
                        > {LastPageLink}<br/>Show {RowsPerPageDropdown} per page",
                        > pageLabelBuilder : function (page, paginator) { var recs =
                        > paginator.getPageRecords(page); return (recs[0] + 1) + ' - ' +
                        > (recs[1] + 1); } }); }
                        >
                        > And then I was attempting to manipulate the paginator in the
                        > handleDataReturnPayload callback.  I didn't know about the
                        > initialPage option -- I just now tried that by adding a
                        > initialPage: 2 to the Paginator init above and it still displays as
                        > being on page 1.  Ideally I wouldn't want to have to calculate the
                        > initial page, I'd rather just tell the Paginator my offset and have
                        > it figure the page itself.
                        >
                        >
                        >
                        > On Mon, Nov 17, 2008 at 7:10 AM, Lucas Smith <lsmith@...
                        > <mailto:lsmith@...>> wrote:
                        >
                        > --- In ydn-javascript@yahoogroups.com
                        > <mailto:ydn-javascript@yahoogroups.com>, "Todd Wells"
                        > <ttopwells@...> wrote:
                        >>
                        >> I'm hoping someone more knowledgeable can respond to this...
                        > this is an
                        >> important use case for my app, where I need the paginator to
                        > correctly
                        >> reflect the displayed page when the intial query is not for
                        > page one.
                        >>
                        >> On Sat, Nov 15, 2008 at 1:44 PM, Todd Wells <ttopwells@...>
                        >> wrote:
                        >>
                        >>> I'm using 2.6.0 and having trouble with a certain use case.
                        > Sometimes when
                        >>> I visit a page with a DataTable, my initial request isn't
                        > for the first page
                        >>> of data -- for example, somebody's navigated away from the page
                        >>>
                        > and then
                        >>> returns, I'm tracking (via YUI history) what the last datatable
                        >>>
                        > query was,
                        >>> and my initial request for data is for the last query.  The
                        > query executes
                        >>> correctly, and the correct page of data is displayed in the
                        > table, but the
                        >>> paginator still indicates it's page 1.  If I try to manually
                        > set the
                        >>> startIndex or page of the paginator (even passing it the
                        > "silent" option),
                        >>> it still doesn't show the correct page, or this confuses the
                        > datatable which
                        >>> displays "no data".  I'm using dynamic data here, by the way.
                        >>>
                        >>> So, if, for example, I know my initial request is offset by 10
                        > (e.g. page 2
                        >>> in a 10-row page), how do I get the paginator to display that
                        >>> it
                        > is on page
                        >>> 2 rather than defaulting to page 1?  So I'm essentially
                        > trying to sync up
                        >>> where the Paginator thinks it is in the dataset with where it
                        > *really* is
                        >>> in the dataset.
                        >>>
                        >>> I've tried handling the payload returned and manually
                        > setting the
                        >>> oPayload.pagination.recordOffset based on metaFields returned
                        >>> by
                        > the server,
                        >>> but this doesn't do the correct thing, either -- I think the
                        > paginator
                        >>> thinks it's dataset is 20 and it should offset by 10, when in
                        > reality only
                        >>> 10 records were returned, they were just already offset.
                        >>>
                        >>>
                        >>>
                        >>>
                        >>>
                        >>
                        >
                        >
                        > Todd,
                        >
                        > Can you post (or post a link to a paste of) the code generating the
                        >  DataTable?  I can have a look and see what may be missing.
                        > Hopefully there isn't a regression in 2.6.
                        >
                        > Incidentally, have you looked at the initialPage config?
                        >
                        > Luke (author of Paginator)
                        >
                        >
                        > ------------------------------------
                        >
                        > Yahoo! Groups Links
                        >
                        >
                        > required)
                        > ______________________________________________________________________
                        >  This email has been scanned by the MessageLabs Email Security
                        > System. For more information please visit
                        > http://www.messagelabs.com/email
                        > ______________________________________________________________________
                        >  <!-- #ygrp-mkp{ border: 1px solid #d8d8d8; font-family: Arial;
                        > margin: 14px 0px; padding: 0px 14px; } #ygrp-mkp hr{ border: 1px
                        > solid #d8d8d8; } #ygrp-mkp #hd{ color: #628c2a; font-size: 85%;
                        > font-weight: bold; line-height: 122%; margin: 10px 0px; } #ygrp-mkp
                        >  #ads{ margin-bottom: 10px; } #ygrp-mkp .ad{ padding: 0 0; }
                        > #ygrp-mkp .ad a{ color: #0000ff; text-decoration: none; } --> <!--
                        > #ygrp-sponsor #ygrp-lc{ font-family: Arial; } #ygrp-sponsor
                        > #ygrp-lc #hd{ margin: 10px 0px; font-weight: bold; font-size: 78%;
                        > line-height: 122%; } #ygrp-sponsor #ygrp-lc .ad{ margin-bottom:
                        > 10px; padding: 0 0; } --> <!-- #ygrp-mlmsg {font-size:13px;
                        > font-family:
                        > arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}
                        > #ygrp-mlmsg table {font-size:inherit;font:100%;} #ygrp-mlmsg
                        > select, input, textarea {font:99%
                        > arial,helvetica,clean,sans-serif;} #ygrp-mlmsg pre, code {font:115%
                        > monospace;*font-size:100%;} #ygrp-mlmsg * {line-height:1.22em;}
                        > #ygrp-text{ font-family: Georgia; } #ygrp-text p{ margin: 0 0 1em
                        > 0; } #ygrp-tpmsgs{ font-family: Arial; clear: both; } #ygrp-vitnav{
                        > padding-top: 10px; font-family: Verdana; font-size: 77%; margin: 0;
                        > } #ygrp-vitnav a{ padding: 0 1px; } #ygrp-actbar{ clear: both;
                        > margin: 25px 0; white-space:nowrap; color: #666; text-align: right;
                        > } #ygrp-actbar .left{ float: left; white-space:nowrap; }
                        > .bld{font-weight:bold;} #ygrp-grft{ font-family: Verdana;
                        > font-size: 77%; padding: 15px 0; } #ygrp-ft{ font-family: verdana;
                        > font-size: 77%; border-top: 1px solid #666; padding: 5px 0; }
                        > #ygrp-mlmsg #logo{ padding-bottom: 10px; } #ygrp-reco {
                        > margin-bottom: 20px; padding: 0px; } #ygrp-reco #reco-head {
                        > font-weight: bold; color: #ff7900; } #reco-grpname{ font-weight:
                        > bold; margin-top: 10px; } #reco-category{ font-size: 77%; }
                        > #reco-desc{ font-size: 77%; } #ygrp-vital{ background-color:
                        > #e0ecee; margin-bottom: 20px; padding: 2px 0 8px 8px; } #ygrp-vital
                        >  #vithd{ font-size: 77%; font-family: Verdana; font-weight: bold;
                        > color: #333; text-transform: uppercase; } #ygrp-vital ul{ padding:
                        > 0; margin: 2px 0; } #ygrp-vital ul li{ list-style-type: none;
                        > clear: both; border: 1px solid #e0ecee; } #ygrp-vital ul li .ct{
                        > font-weight: bold; color: #ff7900; float: right; width: 2em;
                        > text-align:right; padding-right: .5em; } #ygrp-vital ul li .cat{
                        > font-weight: bold; } #ygrp-vital a{ text-decoration: none; }
                        > #ygrp-vital a:hover{ text-decoration: underline; } #ygrp-sponsor
                        > #hd{ color: #999; font-size: 77%; } #ygrp-sponsor #ov{ padding: 6px
                        >  13px; background-color: #e0ecee; margin-bottom: 20px; }
                        > #ygrp-sponsor #ov ul{ padding: 0 0 0 8px; margin: 0; }
                        > #ygrp-sponsor #ov li{ list-style-type: square; padding: 6px 0;
                        > font-size: 77%; } #ygrp-sponsor #ov li a{ text-decoration: none;
                        > font-size: 130%; } #ygrp-sponsor #nc{ background-color: #eee;
                        > margin-bottom: 20px; padding: 0 8px; } #ygrp-sponsor .ad{ padding:
                        > 8px 0; } #ygrp-sponsor .ad #hd1{ font-family: Arial; font-weight:
                        > bold; color: #628c2a; font-size: 100%; line-height: 122%; }
                        > #ygrp-sponsor .ad a{ text-decoration: none; } #ygrp-sponsor .ad
                        > a:hover{ text-decoration: underline; } #ygrp-sponsor .ad p{ margin:
                        > 0; } o{font-size: 0; } .MsoNormal{ margin: 0 0 0 0; } #ygrp-text
                        > tt{ font-size: 120%; } blockquote{margin: 0 0 0 4px;}
                        > .replbq{margin:4} -->
                        -----BEGIN PGP SIGNATURE-----
                        Version: GnuPG v2.0.4-svn0 (GNU/Linux)
                        Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

                        iD8DBQFJIaJTkt7KGge+MvERAsqvAJ9D9hsevArBUApUfuJDTVdtQXFZeACgrmng
                        Q4GMfdnTHMGaXZJYInJCfBM=
                        =jz6t
                        -----END PGP SIGNATURE-----


                        ______________________________________________________________________
                        This email has been scanned by the MessageLabs Email Security System.
                        For more information please visit http://www.messagelabs.com/email
                        ______________________________________________________________________

                        ------------------------------------

                        Yahoo! Groups Links

                        <*> To visit your group on the web, go to:
                           http://groups.yahoo.com/group/ydn-javascript/

                        <*> Your email settings:
                           Individual Email | Traditional

                        <*> To change settings online go to:
                           http://groups.yahoo.com/group/ydn-javascript/join
                           (Yahoo! ID required)

                        <*> To change settings via email:
                           mailto:ydn-javascript-digest@yahoogroups.com
                           mailto:ydn-javascript-fullfeatured@yahoogroups.com

                        <*> To unsubscribe from this group, send an email to:
                           ydn-javascript-unsubscribe@yahoogroups.com

                        <*> Your use of Yahoo! Groups is subject to:
                           http://docs.yahoo.com/info/terms/


                      • Lucas Smith
                        ... I d be ... initialRequest: format=json&*offset=10*&max=10&order=asc&sort=testCase ... Paginator ... [snip] Todd, Your trouble is rooted in the fact that
                        Message 11 of 16 , Nov 18, 2008
                          --- In ydn-javascript@yahoogroups.com, "Todd Wells" <ttopwells@...> wrote:
                          >
                          > In this case, I'm just generating the initial request like this (in this
                          > case my intial offset is contrived, in a browser history situation
                          I'd be
                          > grabbing the initialRequest params from the history manager):
                          >
                          > function getResultsTableConfig() {
                          > var tableWidth;
                          > var minWidth = 1024;
                          > if (document.viewport.getWidth() > minWidth) {
                          > tableWidth = document.viewport.getWidth();
                          > } else {
                          > tableWidth = minWidth;
                          > }
                          > return {
                          >
                          initialRequest:"format=json&*offset=10*&max=10&order=asc&sort=testCase"
                          > + "&filter=" + getCurrentFilter(),
                          > width: tableWidth + "px",
                          > renderLoopSize:10,
                          > generateRequest: buildOutcomeQueryString,
                          > paginator: getResultsPaginator(),
                          > sortedBy: {key:"testCase",
                          > dir:YAHOO.widget.DataTable.CLASS_ASC},
                          > dynamicData: true
                          > };
                          > }
                          >
                          >
                          > function getResultsPaginator() {
                          > return new YAHOO.widget.Paginator({
                          > containers : ['trDetailsPaging'],
                          > pageLinks : 5,
                          > rowsPerPage : 10,
                          > rowsPerPageOptions : [10,15,20,30,50],
                          > template : "{FirstPageLink} {PageLinks}
                          > {LastPageLink}<br/>Show {RowsPerPageDropdown} per page",
                          > pageLabelBuilder : function (page, paginator) {
                          > var recs = paginator.getPageRecords(page);
                          > return (recs[0] + 1) + ' - ' + (recs[1] + 1);
                          > }
                          > });
                          > }
                          >
                          > And then I was attempting to manipulate the paginator in the
                          > handleDataReturnPayload callback. I didn't know about the initialPage
                          > option -- I just now tried that by adding a initialPage: 2 to the
                          Paginator
                          > init above and it still displays as being on page 1. Ideally I wouldn't
                          > want to have to calculate the initial page, I'd rather just tell the
                          > Paginator my offset and have it figure the page itself.
                          >
                          >
                          [snip]

                          Todd,

                          Your trouble is rooted in the fact that Paginator won't accept values
                          passed for recordOffset or initialPage during construction unless
                          totalRecords is also provided.

                          This makes sense from the perspective that Paginator is a standalone
                          widget that DataTable happens to be leveraging. Normally Paginator's
                          totalRecords attribute is required, since it's pretty useless without
                          it. Since DataTable sets these values for you (but not during
                          construction), the timing of setting everything is confusing.

                          You have a couple options for how to proceed:
                          1) pass either recordOffset or initialPage in the constructor as well
                          as a temporary value for totalRecords to facilitate Paginator
                          respecting the provided value.

                          2) include the recordOffset value in your data response and include a
                          metaField for your DataSource to capture it. Then in
                          handleDataReturnPayload, assign the value (after parseInt) to
                          payload.pagination.recordOffset

                          Hope this helps,
                          Luke
                        • Lucas Smith
                          ... I d be ... initialRequest: format=json&*offset=10*&max=10&order=asc&sort=testCase ... Paginator ... [snip] (trying this again, as groups seems to be
                          Message 12 of 16 , Nov 18, 2008
                            --- In ydn-javascript@yahoogroups.com, "Todd Wells" <ttopwells@...> wrote:
                            >
                            > In this case, I'm just generating the initial request like this (in this
                            > case my intial offset is contrived, in a browser history situation
                            I'd be
                            > grabbing the initialRequest params from the history manager):
                            >
                            > function getResultsTableConfig() {
                            > var tableWidth;
                            > var minWidth = 1024;
                            > if (document.viewport.getWidth() > minWidth) {
                            > tableWidth = document.viewport.getWidth();
                            > } else {
                            > tableWidth = minWidth;
                            > }
                            > return {
                            >
                            initialRequest:"format=json&*offset=10*&max=10&order=asc&sort=testCase"
                            > + "&filter=" + getCurrentFilter(),
                            > width: tableWidth + "px",
                            > renderLoopSize:10,
                            > generateRequest: buildOutcomeQueryString,
                            > paginator: getResultsPaginator(),
                            > sortedBy: {key:"testCase",
                            > dir:YAHOO.widget.DataTable.CLASS_ASC},
                            > dynamicData: true
                            > };
                            > }
                            >
                            >
                            > function getResultsPaginator() {
                            > return new YAHOO.widget.Paginator({
                            > containers : ['trDetailsPaging'],
                            > pageLinks : 5,
                            > rowsPerPage : 10,
                            > rowsPerPageOptions : [10,15,20,30,50],
                            > template : "{FirstPageLink} {PageLinks}
                            > {LastPageLink}<br/>Show {RowsPerPageDropdown} per page",
                            > pageLabelBuilder : function (page, paginator) {
                            > var recs = paginator.getPageRecords(page);
                            > return (recs[0] + 1) + ' - ' + (recs[1] + 1);
                            > }
                            > });
                            > }
                            >
                            > And then I was attempting to manipulate the paginator in the
                            > handleDataReturnPayload callback. I didn't know about the initialPage
                            > option -- I just now tried that by adding a initialPage: 2 to the
                            Paginator
                            > init above and it still displays as being on page 1. Ideally I wouldn't
                            > want to have to calculate the initial page, I'd rather just tell the
                            > Paginator my offset and have it figure the page itself.
                            >
                            >
                            >
                            [snip]

                            (trying this again, as groups seems to be having trouble accepting the
                            post. Forgive dups if they all eventually show!)

                            Todd,

                            Your trouble is rooted in the fact that Paginator won't accept values
                            passed for recordOffset or initialPage during construction unless
                            totalRecords is also provided.

                            This makes sense from the perspective that Paginator is a standalone
                            widget that DataTable happens to be leveraging. Normally Paginator's
                            totalRecords attribute is required, since it's pretty useless without
                            it. Since DataTable sets these values for you (but not during
                            construction), the timing of setting everything is confusing.

                            You have a couple options for how to proceed:
                            1) pass either recordOffset or initialPage in the constructor as well
                            as a temporary value for totalRecords to facilitate Paginator
                            respecting the provided value.

                            2) include the recordOffset value in your data response and include a
                            metaField for your DataSource to capture it. Then in
                            handleDataReturnPayload, assign the value (after parseInt) to
                            payload.pagination.recordOffset

                            Hope this helps,
                            Luke
                          • Todd Wells
                            ... Actually (2) is what I was attempting to do that wasn t succeeding. One source of confusion is that oPayload has a totalRecords value which seems
                            Message 13 of 16 , Nov 18, 2008
                              On Tue, Nov 18, 2008 at 7:27 AM, Lucas Smith <lsmith@...> wrote:

                              You have a couple options for how to proceed:
                              1) pass either recordOffset or initialPage in the constructor as well
                              as a temporary value for totalRecords to facilitate Paginator
                              respecting the provided value.

                              2) include the recordOffset value in your data response and include a
                              metaField for your DataSource to capture it.  Then in
                              handleDataReturnPayload, assign the value (after parseInt) to
                              payload.pagination.recordOffset

                              Actually (2) is what I was attempting to do that wasn't succeeding.   One source of confusion is that oPayload has a totalRecords value which seems unrelated to oPayload.pagination.totalRecords, but here I tried setting both values and I end up with the same result, which is the paginator displays page 2, but the datatable itself says "no records found" and displays no records.  Here's what I tried doing:

                                          resultsTable.handleDataReturnPayload = function (oRequest, oResponse, oPayload) {
                                                  if (oPayload) {
                                                      oPayload.totalRecords = oResponse.meta.totalCount;
                                                      oPayload.pagination.totalRecords = oResponse.meta.totalCount;
                                                      oPayload.pagination.recordOffset = oResponse.meta.offset;
                                                      return oPayload;
                                                  } else {
                                                      oPayload = {};
                                                      oPayload.totalRecords = oResponse.meta.totalCount;
                                                      return oPayload;
                                                  }
                                              };

                              It might be worthwhile for you to do some exploratory testing around this scenario: dynamicData with a paginator and the initial request being not on page one.  I could probably put this example up online for you somewhere, but it's non-trivial to do as it involves setting up an app server.

                              The good news is, I just tried approach (1) and it seems to work.  It feels a bit hackish, though, since I don't really know the total number of records before making the query. I suppose I could use the history manager to store the total number of records from the previous time the query was made, but there's not any guarantee that the total number will be the same on the next visit (since data could be modified outside of one particular client). I suppose I could probably make an additional count query before the initial query, but that seems like making the db work more than necessary as well as making an extra round trip to the server.

                              I appreciate your willingness to dig in to this!
                            • lassejohnsen
                              Hi, I m not sure, but I may have identified the solution.... (It works for me and I have a similar problem- would you mind checking if it indeed also works for
                              Message 14 of 16 , Dec 1, 2008
                                Hi,


                                I'm not sure, but I may have identified the solution.... (It works for me and I have a similar
                                problem- would you mind checking if it indeed also works for you?)

                                So.....: My function looks like this:

                                myDataTable.handleDataReturnPayload = function(oRequest, oResponse, oPayload) {

                                oPayload.totalRecords = oResponse.meta.totalRecords;
                                oPayload.pagination.recordOffset = oResponse.meta.paginationRecordOffset;

                                return oPayload;
                                }



                                However due to a particularity in the Yahoo code the function get called too late, so try
                                and redeclare like so:

                                myDataTable.onDataReturnSetRows = function(oRequest, oResponse, oPayload) {


                                var lang = YAHOO.lang,
                                util = YAHOO.util,
                                widget = YAHOO.widget,

                                Dom = util.Dom,
                                Ev = util.Event,
                                DT = widget.DataTable;

                                if((this instanceof DT) && this._sId) {
                                this.fireEvent("dataReturnEvent",
                                {request:oRequest,response:oResponse,payload:oPayload});

                                // Pass data through abstract method for any transformations
                                var ok = this.doBeforeLoadData(oRequest, oResponse, oPayload),
                                pag = this.get('paginator'),
                                index = 0;

                                // Data ok to set
                                if(ok && oResponse && !oResponse.error && lang.isArray(oResponse.results)) {

                                // Update state
                                this._handleDataReturnPayload(oRequest, oResponse, oPayload);
                                // ......to here please?

                                // Update Records
                                if (this.get('dynamicData')) {
                                if (oPayload && oPayload.pagination &&
                                lang.isNumber(oPayload.pagination.recordOffset)) {
                                index = oPayload.pagination.recordOffset;
                                } else if (pag) {
                                index = pag.getStartIndex();
                                }
                                }

                                this._oRecordSet.setRecords(oResponse.results, index | 0);

                                // Update state
                                // this._handleDataReturnPayload(oRequest, oResponse, oPayload);
                                // Dear Dr. Yahoo, could you move this up.......

                                // Update UI
                                this.render();
                                }
                                // Error
                                else if(ok && oResponse.error) {
                                this.showTableMessage(this.get("MSG_ERROR"), DT.CLASS_ERROR);
                                }
                                }
                                else {
                                YAHOO.log("Instance destroyed before data returned.","info",this.toString());
                                }
                                };



                                If it works, or doesn't work or breaks something else that would be good to know.

                                Thank you.

                                /Lasse

                                --- In ydn-javascript@yahoogroups.com, "Todd Wells" <ttopwells@...> wrote:
                                >
                                > On Tue, Nov 18, 2008 at 7:27 AM, Lucas Smith <lsmith@...> wrote:
                                >
                                > >
                                > > You have a couple options for how to proceed:
                                > > 1) pass either recordOffset or initialPage in the constructor as well
                                > > as a temporary value for totalRecords to facilitate Paginator
                                > > respecting the provided value.
                                > >
                                > > 2) include the recordOffset value in your data response and include a
                                > > metaField for your DataSource to capture it. Then in
                                > > handleDataReturnPayload, assign the value (after parseInt) to
                                > > payload.pagination.recordOffset
                                > >
                                >
                                > Actually (2) is what I was attempting to do that wasn't succeeding. One
                                > source of confusion is that oPayload has a totalRecords value which seems
                                > unrelated to oPayload.pagination.totalRecords, but here I tried setting both
                                > values and I end up with the same result, which is the paginator displays
                                > page 2, but the datatable itself says "no records found" and displays no
                                > records. Here's what I tried doing:
                                >
                                > resultsTable.handleDataReturnPayload = function (oRequest,
                                > oResponse, oPayload) {
                                > if (oPayload) {
                                > oPayload.totalRecords = oResponse.meta.totalCount;
                                > oPayload.pagination.totalRecords =
                                > oResponse.meta.totalCount;
                                > oPayload.pagination.recordOffset =
                                > oResponse.meta.offset;
                                > return oPayload;
                                > } else {
                                > oPayload = {};
                                > oPayload.totalRecords = oResponse.meta.totalCount;
                                > return oPayload;
                                > }
                                > };
                                >
                                > It might be worthwhile for you to do some exploratory testing around this
                                > scenario: dynamicData with a paginator and the initial request being not on
                                > page one. I could probably put this example up online for you somewhere,
                                > but it's non-trivial to do as it involves setting up an app server.
                                >
                                > The good news is, I just tried approach (1) and it seems to work. It feels
                                > a bit hackish, though, since I don't really know the total number of records
                                > before making the query. I suppose I could use the history manager to store
                                > the total number of records from the previous time the query was made, but
                                > there's not any guarantee that the total number will be the same on the next
                                > visit (since data could be modified outside of one particular client). I
                                > suppose I could probably make an additional count query before the initial
                                > query, but that seems like making the db work more than necessary as well as
                                > making an extra round trip to the server.
                                >
                                > I appreciate your willingness to dig in to this!
                                >
                              • D. Wayne Fincher
                                I m having the same exact problem. I can get one of two results: 1) The datatable shows the correct date for the correct page, but the nav shows the wrong page
                                Message 15 of 16 , Dec 1, 2008
                                  I'm having the same exact problem. I can get one of two results:

                                  1) The datatable shows the correct date for the correct page, but the
                                  nav shows the wrong page number. This happens if I don't use this line
                                  of code ---> oPayload.pagination.recordOffset = oResponse.meta.startIndex;


                                  2) If I do use that line of code, the nav shows the correct page
                                  number, but the datatable incorrectly says there is no data to display.

                                  this.dTable.handleDataReturnPayload = function(oRequest, oResponse,
                                  oPayload) {
                                  oPayload.totalRecords = oResponse.meta.totalRecords;
                                  oPayload.pagination.recordOffset = oResponse.meta.startIndex;
                                  return oPayload;
                                  }

                                  That's what my Payload handler looks like. There must be something
                                  else I'm missing here?


                                  Lasse, sorry, but I didn't understand your suggested solution.


                                  --- In ydn-javascript@yahoogroups.com, "lassejohnsen"
                                  <lasse.johnsen@...> wrote:
                                  >
                                  > Hi,
                                  >
                                  >
                                  > I'm not sure, but I may have identified the solution.... (It works
                                  for me and I have a similar
                                  > problem- would you mind checking if it indeed also works for you?)
                                  >
                                  > So.....: My function looks like this:
                                  >
                                  > myDataTable.handleDataReturnPayload = function(oRequest, oResponse,
                                  oPayload) {
                                  >
                                  > oPayload.totalRecords = oResponse.meta.totalRecords;
                                  > oPayload.pagination.recordOffset =
                                  oResponse.meta.paginationRecordOffset;
                                  >
                                  > return oPayload;
                                  > }
                                  >
                                  >
                                  >
                                  > However due to a particularity in the Yahoo code the function get
                                  called too late, so try
                                  > and redeclare like so:
                                  >
                                  > myDataTable.onDataReturnSetRows = function(oRequest, oResponse,
                                  oPayload) {
                                  >
                                  >
                                  > var lang = YAHOO.lang,
                                  > util = YAHOO.util,
                                  > widget = YAHOO.widget,
                                  >
                                  > Dom = util.Dom,
                                  > Ev = util.Event,
                                  > DT = widget.DataTable;
                                  >
                                  > if((this instanceof DT) && this._sId) {
                                  > this.fireEvent("dataReturnEvent",
                                  > {request:oRequest,response:oResponse,payload:oPayload});
                                  >
                                  > // Pass data through abstract method for any transformations
                                  > var ok = this.doBeforeLoadData(oRequest, oResponse, oPayload),
                                  > pag = this.get('paginator'),
                                  > index = 0;
                                  >
                                  > // Data ok to set
                                  > if(ok && oResponse && !oResponse.error &&
                                  lang.isArray(oResponse.results)) {
                                  >
                                  > // Update state
                                  > this._handleDataReturnPayload(oRequest, oResponse, oPayload);
                                  > // ......to here please?
                                  >
                                  > // Update Records
                                  > if (this.get('dynamicData')) {
                                  > if (oPayload && oPayload.pagination &&
                                  > lang.isNumber(oPayload.pagination.recordOffset)) {
                                  > index = oPayload.pagination.recordOffset;
                                  > } else if (pag) {
                                  > index = pag.getStartIndex();
                                  > }
                                  > }
                                  >
                                  > this._oRecordSet.setRecords(oResponse.results, index | 0);
                                  >
                                  > // Update state
                                  > // this._handleDataReturnPayload(oRequest, oResponse,
                                  oPayload);
                                  > // Dear Dr. Yahoo, could you move this up.......
                                  >
                                  > // Update UI
                                  > this.render();
                                  > }
                                  > // Error
                                  > else if(ok && oResponse.error) {
                                  > this.showTableMessage(this.get("MSG_ERROR"), DT.CLASS_ERROR);
                                  > }
                                  > }
                                  > else {
                                  > YAHOO.log("Instance destroyed before data
                                  returned.","info",this.toString());
                                  > }
                                  > };
                                  >
                                  >
                                  >
                                  > If it works, or doesn't work or breaks something else that would be
                                  good to know.
                                  >
                                  > Thank you.
                                  >
                                  > /Lasse
                                  >
                                  > --- In ydn-javascript@yahoogroups.com, "Todd Wells" <ttopwells@> wrote:
                                  > >
                                  > > On Tue, Nov 18, 2008 at 7:27 AM, Lucas Smith <lsmith@> wrote:
                                  > >
                                  > > >
                                  > > > You have a couple options for how to proceed:
                                  > > > 1) pass either recordOffset or initialPage in the constructor as
                                  well
                                  > > > as a temporary value for totalRecords to facilitate Paginator
                                  > > > respecting the provided value.
                                  > > >
                                  > > > 2) include the recordOffset value in your data response and
                                  include a
                                  > > > metaField for your DataSource to capture it. Then in
                                  > > > handleDataReturnPayload, assign the value (after parseInt) to
                                  > > > payload.pagination.recordOffset
                                  > > >
                                  > >
                                  > > Actually (2) is what I was attempting to do that wasn't
                                  succeeding. One
                                  > > source of confusion is that oPayload has a totalRecords value
                                  which seems
                                  > > unrelated to oPayload.pagination.totalRecords, but here I tried
                                  setting both
                                  > > values and I end up with the same result, which is the paginator
                                  displays
                                  > > page 2, but the datatable itself says "no records found" and
                                  displays no
                                  > > records. Here's what I tried doing:
                                  > >
                                  > > resultsTable.handleDataReturnPayload = function (oRequest,
                                  > > oResponse, oPayload) {
                                  > > if (oPayload) {
                                  > > oPayload.totalRecords =
                                  oResponse.meta.totalCount;
                                  > > oPayload.pagination.totalRecords =
                                  > > oResponse.meta.totalCount;
                                  > > oPayload.pagination.recordOffset =
                                  > > oResponse.meta.offset;
                                  > > return oPayload;
                                  > > } else {
                                  > > oPayload = {};
                                  > > oPayload.totalRecords =
                                  oResponse.meta.totalCount;
                                  > > return oPayload;
                                  > > }
                                  > > };
                                  > >
                                  > > It might be worthwhile for you to do some exploratory testing
                                  around this
                                  > > scenario: dynamicData with a paginator and the initial request
                                  being not on
                                  > > page one. I could probably put this example up online for you
                                  somewhere,
                                  > > but it's non-trivial to do as it involves setting up an app server.
                                  > >
                                  > > The good news is, I just tried approach (1) and it seems to work.
                                  It feels
                                  > > a bit hackish, though, since I don't really know the total number
                                  of records
                                  > > before making the query. I suppose I could use the history manager
                                  to store
                                  > > the total number of records from the previous time the query was
                                  made, but
                                  > > there's not any guarantee that the total number will be the same
                                  on the next
                                  > > visit (since data could be modified outside of one particular
                                  client). I
                                  > > suppose I could probably make an additional count query before the
                                  initial
                                  > > query, but that seems like making the db work more than necessary
                                  as well as
                                  > > making an extra round trip to the server.
                                  > >
                                  > > I appreciate your willingness to dig in to this!
                                  > >
                                  >
                                • Lucas Smith
                                  Here are two solutions: function toQuery(state) { return offset= +state.pagination.recordOffset+ &recs= +state.pagination.rowsPerPage; } function
                                  Message 16 of 16 , Dec 12, 2008
                                    Here are two solutions:

                                    function toQuery(state) {
                                        return "offset="+state.pagination.recordOffset+
                                               "&recs="+state.pagination.rowsPerPage;
                                    }
                                    function handlePayload(req,res,payload) {
                                        // you should always parseInt meta values for Paginator
                                        payload.totalRecords = parseInt(res.meta.totalRecords,10);
                                        return payload;
                                    }

                                    // Solution 1: pass the recordOffset
                                    var initialOffset = 10;

                                    var paginator = new Paginator({
                                        rowsPerPage : 10,
                                        recordOffset: initialOffset,
                                        totalRecords: Number.MAX_VALUE // large number needed here
                                    });

                                    // initialRequest also includes initial recordOffset
                                    var conf = {
                                        initialRequest  : 'offset=' + initialOffset + '&recs=10',
                                        paginator       : paginator,
                                        dynamicData     : true,
                                        generateRequest : toQuery
                                    };

                                    var dataTable = new DataTable('tbl', colDef, dataSource, conf);
                                    dataTable.handleDataReturnPayload = handlePayload;


                                    // Solution 2: pass the initialPage and manually request initial data
                                    var initialPage = 2;

                                    var paginator = new Paginator({
                                        rowsPerPage : 10,
                                        initialPage : initialPage,
                                        totalRecords: Number.MAX_VALUE // arbitrary high number
                                    });

                                    var conf = {
                                        initialLoad     : false, // cancel the default send
                                        paginator       : paginator,
                                        dynamicData     : true,
                                        generateRequest : toQuery
                                    };

                                    dataTable = new DataTable('tbl', colDef, dataSource, conf);
                                    dataTable.handleDataReturnPayload = handlePayload;

                                    // Manually get the data using the DataTable's getState() passed to its generateRequest function
                                    dataSource.sendRequest(
                                        dataTable.get('generateRequest')(dataTable.getState()), // this is important
                                        {
                                            success  : dataTable.onDataReturnInitializeTable,
                                            scope    : dataTable,
                                            argument : dataTable.getState()
                                        });


                                    Hope this helps,
                                    Luke

                                    --- In ydn-javascript@yahoogroups.com, "D. Wayne Fincher" <slowlychillin@...> wrote:
                                    >
                                    > I'm having the same exact problem. I can get one of two results:
                                    >
                                    > 1) The datatable shows the correct date for the correct page, but the
                                    > nav shows the wrong page number. This happens if I don't use this line
                                    > of code ---> oPayload.pagination.recordOffset = oResponse.meta.startIndex;
                                    >
                                    >
                                    > 2) If I do use that line of code, the nav shows the correct page
                                    > number, but the datatable incorrectly says there is no data to display.
                                    >
                                    > this.dTable.handleDataReturnPayload = function(oRequest, oResponse,
                                    > oPayload) {
                                    > oPayload.totalRecords = oResponse.meta.totalRecords;
                                    > oPayload.pagination.recordOffset = oResponse.meta.startIndex;
                                    > return oPayload;
                                    > }
                                    >
                                    > That's what my Payload handler looks like. There must be something
                                    > else I'm missing here?
                                    >
                                    >
                                    > Lasse, sorry, but I didn't understand your suggested solution.
                                    >
                                    >
                                    > --- In ydn-javascript@yahoogroups.com, "lassejohnsen"
                                    > lasse.johnsen@ wrote:
                                    > >
                                    > > Hi,
                                    > >
                                    > >
                                    > > I'm not sure, but I may have identified the solution.... (It works
                                    > for me and I have a similar
                                    > > problem- would you mind checking if it indeed also works for you?)
                                    > >
                                    > > So.....: My function looks like this:
                                    > >
                                    > > myDataTable.handleDataReturnPayload = function(oRequest, oResponse,
                                    > oPayload) {
                                    > >
                                    > > oPayload.totalRecords = oResponse.meta.totalRecords;
                                    > > oPayload.pagination.recordOffset =
                                    > oResponse.meta.paginationRecordOffset;
                                    > >
                                    > > return oPayload;
                                    > > }
                                    > >
                                    > >
                                    > >
                                    > > However due to a particularity in the Yahoo code the function get
                                    > called too late, so try
                                    > > and redeclare like so:
                                    > >
                                    > > myDataTable.onDataReturnSetRows = function(oRequest, oResponse,
                                    > oPayload) {
                                    > >
                                    > >
                                    > > var lang = YAHOO.lang,
                                    > > util = YAHOO.util,
                                    > > widget = YAHOO.widget,
                                    > >
                                    > > Dom = util.Dom,
                                    > > Ev = util.Event,
                                    > > DT = widget.DataTable;
                                    > >
                                    > > if((this instanceof DT) && this._sId) {
                                    > > this.fireEvent("dataReturnEvent",
                                    > > {request:oRequest,response:oResponse,payload:oPayload});
                                    > >
                                    > > // Pass data through abstract method for any transformations
                                    > > var ok = this.doBeforeLoadData(oRequest, oResponse, oPayload),
                                    > > pag = this.get('paginator'),
                                    > > index = 0;
                                    > >
                                    > > // Data ok to set
                                    > > if(ok && oResponse && !oResponse.error &&
                                    > lang.isArray(oResponse.results)) {
                                    > >
                                    > > // Update state
                                    > > this._handleDataReturnPayload(oRequest, oResponse, oPayload);
                                    > > // ......to here please?
                                    > >
                                    > > // Update Records
                                    > > if (this.get('dynamicData')) {
                                    > > if (oPayload && oPayload.pagination &&
                                    > > lang.isNumber(oPayload.pagination.recordOffset)) {
                                    > > index = oPayload.pagination.recordOffset;
                                    > > } else if (pag) {
                                    > > index = pag.getStartIndex();
                                    > > }
                                    > > }
                                    > >
                                    > > this._oRecordSet.setRecords(oResponse.results, index | 0);
                                    > >
                                    > > // Update state
                                    > > // this._handleDataReturnPayload(oRequest, oResponse,
                                    > oPayload);
                                    > > // Dear Dr. Yahoo, could you move this up.......
                                    > >
                                    > > // Update UI
                                    > > this.render();
                                    > > }
                                    > > // Error
                                    > > else if(ok && oResponse.error) {
                                    > > this.showTableMessage(this.get("MSG_ERROR"), DT.CLASS_ERROR);
                                    > > }
                                    > > }
                                    > > else {
                                    > > YAHOO.log("Instance destroyed before data
                                    > returned.","info",this.toString());
                                    > > }
                                    > > };
                                    > >
                                    > >
                                    > >
                                    > > If it works, or doesn't work or breaks something else that would be
                                    > good to know.
                                    > >
                                    > > Thank you.
                                    > >
                                    > > /Lasse
                                    > >
                                    > > --- In ydn-javascript@yahoogroups.com, "Todd Wells" <ttopwells@> wrote:
                                    > > >
                                    > > > On Tue, Nov 18, 2008 at 7:27 AM, Lucas Smith <lsmith@> wrote:
                                    > > >
                                    > > > >
                                    > > > > You have a couple options for how to proceed:
                                    > > > > 1) pass either recordOffset or initialPage in the constructor as
                                    > well
                                    > > > > as a temporary value for totalRecords to facilitate Paginator
                                    > > > > respecting the provided value.
                                    > > > >
                                    > > > > 2) include the recordOffset value in your data response and
                                    > include a
                                    > > > > metaField for your DataSource to capture it. Then in
                                    > > > > handleDataReturnPayload, assign the value (after parseInt) to
                                    > > > > payload.pagination.recordOffset
                                    > > > >
                                    > > >
                                    > > > Actually (2) is what I was attempting to do that wasn't
                                    > succeeding. One
                                    > > > source of confusion is that oPayload has a totalRecords value
                                    > which seems
                                    > > > unrelated to oPayload.pagination.totalRecords, but here I tried
                                    > setting both
                                    > > > values and I end up with the same result, which is the paginator
                                    > displays
                                    > > > page 2, but the datatable itself says "no records found" and
                                    > displays no
                                    > > > records. Here's what I tried doing:
                                    > > >
                                    > > > resultsTable.handleDataReturnPayload = function (oRequest,
                                    > > > oResponse, oPayload) {
                                    > > > if (oPayload) {
                                    > > > oPayload.totalRecords =
                                    > oResponse.meta.totalCount;
                                    > > > oPayload.pagination.totalRecords =
                                    > > > oResponse.meta.totalCount;
                                    > > > oPayload.pagination.recordOffset =
                                    > > > oResponse.meta.offset;
                                    > > > return oPayload;
                                    > > > } else {
                                    > > > oPayload = {};
                                    > > > oPayload.totalRecords =
                                    > oResponse.meta.totalCount;
                                    > > > return oPayload;
                                    > > > }
                                    > > > };
                                    > > >
                                    > > > It might be worthwhile for you to do some exploratory testing
                                    > around this
                                    > > > scenario: dynamicData with a paginator and the initial request
                                    > being not on
                                    > > > page one. I could probably put this example up online for you
                                    > somewhere,
                                    > > > but it's non-trivial to do as it involves setting up an app server.
                                    > > >
                                    > > > The good news is, I just tried approach (1) and it seems to work.
                                    > It feels
                                    > > > a bit hackish, though, since I don't really know the total number
                                    > of records
                                    > > > before making the query. I suppose I could use the history manager
                                    > to store
                                    > > > the total number of records from the previous time the query was
                                    > made, but
                                    > > > there's not any guarantee that the total number will be the same
                                    > on the next
                                    > > > visit (since data could be modified outside of one particular
                                    > client). I
                                    > > > suppose I could probably make an additional count query before the
                                    > initial
                                    > > > query, but that seems like making the db work more than necessary
                                    > as well as
                                    > > > making an extra round trip to the server.
                                    > > >
                                    > > > I appreciate your willingness to dig in to this!
                                    > > >
                                    > >
                                    >
                                  Your message has been successfully submitted and would be delivered to recipients shortly.