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

Re: {Disarmed} Re: [ydn-javascript] Re: Paginator Links

Expand Messages
  • Marco Mariani
    ... dt_serverpaginat ion_source. html ... The data error is definitely
    Message 1 of 14 , Oct 10, 2007
    • 0 Attachment
      Satyam ha scritto:

      > Ok well go to this example
      >
      > http://developer. yahoo.com/ yui/examples/ datatable/
      dt_serverpaginat ion_source. html
      <http://developer.yahoo.com/yui/examples/datatable/dt_serverpagination_source.html>
      >
      > go to the end of the the records. You will get a data error.

      > I did, and I don't, not even a warning, not in Firefox at least.
      >

      The data error is definitely there, not from javascript but from the yui
      widget, because the table lets you click on 'next page' even at the end
      of the list, without properly checking boundaries.

      I found it out as well, when I adapted the example to my needs.
    • jerry_gagliano
      I get an data error and tested in firefox and IE7. When you go to the end of the records which is the 1397th record it give you a data error. If you do
      Message 2 of 14 , Oct 10, 2007
      • 0 Attachment
        I get an data error and tested in firefox and IE7.

        When you go to the end of the records which is the 1397th record it
        give you a data error.

        If you do continue clicking on the next link the the number passes
        1397 even if there are no records.

        So i think personally yahoo should make there examples work properly
        before posting them up to avoid any complications.



        --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@...> wrote:
        >
        > I did, and I don't, not even a warning, not in Firefox at least.
        >
        > ----- Original Message -----
        > From: "jerry_gagliano" <jerry.gagliano@...>
        > To: <ydn-javascript@yahoogroups.com>
        > Sent: Wednesday, October 10, 2007 5:00 PM
        > Subject: [ydn-javascript] Re: Paginator Links
        >
        >
        > > Ok well go to this example
        > >
        > >
        http://developer.yahoo.com/yui/examples/datatable/dt_serverpagination_source.html
        > >
        > > go to the end of the the records. You will get a data error.
        > >
        > >
        > > --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@> wrote:
        > >>
        > >> Sorry, I assumed you have copied them because you have mentioned
        > > this code:
        > >>
        > >> initialRequest: "startIndex=0&results=5"
        > >>
        > >> but the original asks for 25, not 5, so I assumed that you have
        > > copied it
        > >> somewhere and changed it. Also because, as it is in the server, it
        > > works
        > >> both in Firefox and IE7 as far as I can tell, though I'm sure it has
        > > been
        > >> tested in all the supported browsers.
        > >>
        > >> Satyam
        > >>
        > >>
        > >> ----- Original Message -----
        > >> From: "jerry_gagliano" <jerry.gagliano@>
        > >> To: <ydn-javascript@yahoogroups.com>
        > >> Sent: Wednesday, October 10, 2007 4:19 PM
        > >> Subject: [ydn-javascript] Re: Paginator Links
        > >>
        > >>
        > >> > These samples are withing the yahoo UI website. There not on my own
        > >> > server.
        > >> >
        > >> > There are bugs in the datatable examples. then again it's a beta
        > >> > version so I expect it to be errors
        > >> >
        > >> > Now I am just wondering when is a new release coming out?
        > >> >
        > >> > --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@> wrote:
        > >> >>
        > >> >> Jerry
        > >> >>
        > >> >> This are all the styles I set to provide first, last, previous
        > > and next
        > >> >> buttons but no page numbers:
        > >> >>
        > >> >> <style>
        > >> >> .yui-skin-sam a.yui-dt-page
        > >> >> {
        > >> >> display:none;
        > >> >> }
        > >> >> .yui-skin-sam span.yui-dt-selected
        > >> >> {
        > >> >> display:none;
        > >> >> }
        > >> >> .yui-skin-sam .yui-dt-paginator .yui-dt-previous, .yui-skin-sam
        > >> >> .yui-dt-paginator .yui-dt-next
        > >> >> {
        > >> >> display:inline;
        > >> >> }
        > >> >>
        > >> >> </style>
        > >> >>
        > >> >> Otherwise, notice that in the API documentation for DataTable,
        there
        > >> > are
        > >> >> lots of literals for the names of the classes you want to apply to
        > >> > links.
        > >> >> The styles above are for the standard class names, but you can
        even
        > >> > change
        > >> >> those and point to your own classes.
        > >> >>
        > >> >> As for the samples not working, when you move them over your own
        > >> > server many
        > >> >> relative links will break since they rely on the structure of
        YUI's
        > >> > samples
        > >> >> site. Also, requests for data will also fail since that would be
        > >> > cross-site
        > >> >> linking, which browsers forbid for security reasons. You cannot
        > >> > access the
        > >> >> data at a location other than the same server. All sorts of
        things
        > >> > will
        > >> >> break in unpredictable ways.
        > >> >>
        > >> >> Satyam
        > >> >>
        > >> >> ----- Original Message -----
        > >> >> From: "jerry_gagliano" <jerry.gagliano@>
        > >> >> To: <ydn-javascript@yahoogroups.com>
        > >> >> Sent: Tuesday, October 09, 2007 9:30 PM
        > >> >> Subject: [ydn-javascript] Re: Paginator Links
        > >> >>
        > >> >>
        > >> >> > Ok i am getting some where but i am following this example
        > >> >> >
        > >> >> >
        > >> >
        > >
        http://developer.yahoo.com/yui/examples/datatable/dt_serverpagination_source.html
        > >> >> >
        > >> >> > Now the problem is that this line:
        > >> >> >
        > >> >> > initialRequest: "startIndex=0&results=5"
        > >> >> >
        > >> >> > doesn't work when the page is first loaded. I also get a
        javascript
        > >> >> > error on line 249 on the json.js file which i included from
        > > yahoo UI.
        > >> >> >
        > >> >> > if I comment it out the data loads but i can't go to the next
        > > set of
        > >> >> > records.
        > >> >> >
        > >> >> > any clues anyone?
        > >> >> >
        > >> >> > --- In ydn-javascript@yahoogroups.com, "jerry_gagliano"
        > >> >> > <jerry.gagliano@> wrote:
        > >> >> >>
        > >> >> >> Can you give a small example.
        > >> >> >>
        > >> >> >> I added the style like you said but it doesn't work properly.
        > >> >> >>
        > >> >> >> So if i have 30 records in total showing 5 records per page
        which
        > >> > is 6
        > >> >> >> page well i still see 1 in the middle and when i click on
        next it
        > >> > goes
        > >> >> >> to the last page which is 6.
        > >> >> >>
        > >> >> >> Doesn't look like a good solution.
        > >> >> >>
        > >> >> >> --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@>
        wrote:
        > >> >> >> >
        > >> >> >> > Since the pageLinks configuration attribute, when set to
        0 means
        > >> >> >> show all,
        > >> >> >> > you might have to use styles. Each paginator link has a
        > > specific
        > >> >> >> style.
        > >> >> >> > You could add a definition to that same style so that the
        link
        > >> > is not
        > >> >> >> > visible, such as
        > >> >> >> >
        > >> >> >> > <style>
        > >> >> >> > .yui-skin-sam a.yui-dt-page
        > >> >> >> > {
        > >> >> >> > display:none;
        > >> >> >> > }
        > >> >> >> > .yui-skin-sam a.yui-dt-selected
        > >> >> >> > {
        > >> >> >> > display:none;
        > >> >> >> > }
        > >> >> >> > </style>
        > >> >> >> >
        > >> >> >> > You don't need to edit the provided stylesheet, you can
        add the
        > >> >> >> above code
        > >> >> >> > to your page and those particular styles will be added to
        those
        > >> >> > already
        > >> >> >> > existing and, in this case, will render them pointless
        for that
        > >> >> >> page. I
        > >> >> >> > just tried that with Firebug in the client-side paginator
        > >> > example, I
        > >> >> >> hope it
        > >> >> >> > works for you.
        > >> >> >> >
        > >> >> >> > Satyam
        > >> >> >> >
        > >> >> >> >
        > >> >> >> > ----- Original Message -----
        > >> >> >> > From: "jerry_gagliano" <jerry.gagliano@>
        > >> >> >> > To: <ydn-javascript@yahoogroups.com>
        > >> >> >> > Sent: Tuesday, October 09, 2007 5:47 PM
        > >> >> >> > Subject: [ydn-javascript] Re: Paginator Links
        > >> >> >> >
        > >> >> >> >
        > >> >> >> > > --- In ydn-javascript@yahoogroups.com, "jackson0810"
        > >> >> >> > > <Derrick_Jackson@> wrote:
        > >> >> >> > >>
        > >> >> >> > >> Hi,
        > >> >> >> > >>
        > >> >> >> > >> I would like to use my own Next and Previous links for the
        > >> >> > paginator.
        > >> >> >> > >> Currently I see something like this: << < 1 2 3 > >>
        but I
        > >> > would
        > >> >> >> like
        > >> >> >> > >> to change this.
        > >> >> >> > >>
        > >> >> >> > >> Have any of you figured this out or am I missing
        > > something that
        > >> >> >> is tiny?
        > >> >> >> > >>
        > >> >> >> > >
        > >> >> >> > > I am looking for a next and previous buttons only. Any
        > >> > solution to
        > >> >> >> this?
        > >> >> >> > >
        > >> >> >> > > Thanks
        > >> >> >> > >
        > >> >> >> > >
        > >> >> >> > >
        > >> >> >> > >
        > >> >> >> > >
        > >> >> >> > > Yahoo! Groups Links
        > >> >> >> > >
        > >> >> >> > >
        > >> >> >> > >
        > >> >> >> > >
        > >> >> >> > >
        > >> >> >> > > --
        > >> >> >> > > No virus found in this incoming message.
        > >> >> >> > > Checked by AVG Free Edition.
        > >> >> >> > > Version: 7.5.488 / Virus Database: 269.14.5/1058 - Release
        > > Date:
        > >> >> >> > > 08/10/2007 16:54
        > >> >> >> > >
        > >> >> >> > >
        > >> >> >> >
        > >> >> >>
        > >> >> >
        > >> >> >
        > >> >> >
        > >> >> >
        > >> >> >
        > >> >> > Yahoo! Groups Links
        > >> >> >
        > >> >> >
        > >> >> >
        > >> >> >
        > >> >> >
        > >> >> > --
        > >> >> > No virus found in this incoming message.
        > >> >> > Checked by AVG Free Edition.
        > >> >> > Version: 7.5.488 / Virus Database: 269.14.5/1058 - Release Date:
        > >> >> > 08/10/2007 16:54
        > >> >> >
        > >> >> >
        > >> >>
        > >> >
        > >> >
        > >> >
        > >> >
        > >> >
        > >> > Yahoo! Groups Links
        > >> >
        > >> >
        > >> >
        > >> >
        > >> >
        > >> > --
        > >> > No virus found in this incoming message.
        > >> > Checked by AVG Free Edition.
        > >> > Version: 7.5.488 / Virus Database: 269.14.6/1060 - Release Date:
        > >> > 09/10/2007 16:43
        > >> >
        > >>
        > >
        > >
        > >
        > >
        > >
        > > Yahoo! Groups Links
        > >
        > >
        > >
        > >
        > >
        > > --
        > > No virus found in this incoming message.
        > > Checked by AVG Free Edition.
        > > Version: 7.5.488 / Virus Database: 269.14.6/1060 - Release Date:
        > > 09/10/2007 16:43
        > >
        >
      • y_lsmith
        ... http://developer.yahoo.com/yui/examples/datatable/dt_serverpagination_source.html ... Jerry, This indeed looks like a bug at least in the example, if not
        Message 3 of 14 , Oct 11, 2007
        • 0 Attachment
          --- In ydn-javascript@yahoogroups.com, "jerry_gagliano"
          <jerry.gagliano@...> wrote:
          >
          http://developer.yahoo.com/yui/examples/datatable/dt_serverpagination_source.html
          >
          > go to the end of the the records. You will get a data error.
          >

          Jerry,

          This indeed looks like a bug at least in the example, if not the
          underlying code. Please submit the bug to sourceforge and we'll take
          care of it.

          We try to keep the examples in proper working order as the code
          evolves, but as you've shown, sometimes things slip through the
          cracks. Thanks for keeping us honest!

          Regard,
          Luke
        • Satyam
          I m sorry I didn t think to go beyond the last record I just went to the last and that works fine. So, I did go to the last record and then one beyond and,
          Message 4 of 14 , Oct 12, 2007
          • 0 Attachment
            I'm sorry I didn't think to go beyond the last record I just went to the
            last and that works fine. So, I did go to the last record and then one
            beyond and, indeed, it has several errors. I also want to apologize to
            Jerry, I wasn't serious in my replies to him.

            So, let me fix that, the example has several bugs.

            1) The php back end has one, which is the one that causes the "data error".
            When it is asked for a range of records beyond what it can deliver, it
            returns, as part of the reply:

            "records":null

            and it should return:

            "records":[];

            This is due to a failure to initialize variable $data before its first use,
            right before the loop:

            $data = array(); // <== this is the missing line
            for($i=$startIndex; $i<($lastIndex); $i++) {
            $data[] = $allRecords[$i];
            }

            2) the example file dt_serverpagination_source.html has a misspelled
            variable:

            rowsThispage which should be: rowsThisPage

            Anyway, correcting this would make a different error. The properties of
            this.myDataTable.get("paginator") are not updated correctly. After all, for
            all the client knows, the totalRecords is always calculated based on the
            length of the current recordset so, even if you try to update it via the
            updatePaginator method, this particular variable won't be updated and will
            always be 25 or less, the actual number of records the client knows about.

            3) Anyway, the argument passed to updatePaginator is wrong. It tries to set
            a setting totalResults, which does not exist, instead of totalRecords. The
            problem is that method updatePaginator only updates values of already
            existing properties, it does check that the property actually exists before
            setting it simply before it checks for hasOwnProperty to skip over method
            toJSONString and so it also skips over any other variable that you would
            want to add.

            So, we cannot set totalRecords because it is calculated and we cannot set
            totalResults because it rejects it. By the time it gets to check whether it
            accepts a further click, once fixed the misspelling of rowsThisPage, it
            never succeeds since it won't ever know it has more than 25.

            4) The whole idea of using the paginator variables is not a good one. The
            paginator variables have a life of their own with too many side-effects
            which you have to work around and, in the end, confuse the reader to no
            avail. The best is to simply declare the variables local to the example
            main function:

            YAHOO.example.ServerPagination = new function() {
            var totalRecords, recordsReturned , startIndex , endIndex ,
            rowsPerPage = 25;

            and make all the calculations based on them.

            5) The last of those variables rowsPerPage fixes another issue. Once you
            get to the end, the last page will not have 25 records on that page. When
            you go back, instead of going 25 records at a time, it will go back by
            whatever number of records got in the last page. Since in the last page you
            get 22 records, it is barely noticeable but if the remainder was a single
            record, that would be really bad.

            6) Finally, the 'next' link should not be even enabled. This is due to the
            following line:

            YAHOO.util.Dom.get("nextLink").innerHTML =
            (endIndex >= totalRecords) ? ">" :
            "<a href=\"#next\" alt=\"Show next items\">></a>";

            Since records are zero based, endIndex for the last record is one less than
            the record count so the comparison always fails. It should read:

            YAHOO.util.Dom.get("nextLink").innerHTML =
            (endIndex + 1 >= totalRecords) ? ">" :
            "<a href=\"#next\" alt=\"Show next items\">></a>";

            I filed the errors and the fixed file to SourceForge:

            http://sourceforge.net/tracker/index.php?func=detail&aid=1812126&group_id=165715&atid=836476

            Satyam

            ----- Original Message -----
            From: "y_lsmith" <lsmith@...>
            To: <ydn-javascript@yahoogroups.com>
            Sent: Thursday, October 11, 2007 6:59 PM
            Subject: [ydn-javascript] Re: Paginator Links


            > --- In ydn-javascript@yahoogroups.com, "jerry_gagliano"
            > <jerry.gagliano@...> wrote:
            >>
            > http://developer.yahoo.com/yui/examples/datatable/dt_serverpagination_source.html
            >>
            >> go to the end of the the records. You will get a data error.
            >>
            >
            > Jerry,
            >
            > This indeed looks like a bug at least in the example, if not the
            > underlying code. Please submit the bug to sourceforge and we'll take
            > care of it.
            >
            > We try to keep the examples in proper working order as the code
            > evolves, but as you've shown, sometimes things slip through the
            > cracks. Thanks for keeping us honest!
            >
            > Regard,
            > Luke
            >
            >
            >
            >
            > Yahoo! Groups Links
            >
            >
            >
            >
            >
            > --
            > No virus found in this incoming message.
            > Checked by AVG Free Edition.
            > Version: 7.5.488 / Virus Database: 269.14.7/1062 - Release Date:
            > 10/10/2007 17:11
            >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.