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

Datatable Paginator: How to start on Page 1 after selecting new dropdownoption?

Expand Messages
  • roallen2
    I have a table with 100 entries. I m using Paginator with a default rowsperpage set to 25 and dropdownoptions of 50 and 100. If someone clicks on page 4 and
    Message 1 of 5 , Dec 31, 2007
      I have a table with 100 entries. I'm using Paginator with a default
      rowsperpage set to 25 and dropdownoptions of 50 and 100. If someone
      clicks on page 4 and then selects 50 or 100 from the dropdown, the
      table shows "No records". You have to click on the page 1/2 links to
      see any records. Is there a way to have the table start on Page 1
      after someone selects from the drop down menu (using an inline table
      as the data source)?

      My code is below. Thanks!


      <script type="text/javascript">
      YAHOO.util.Event.addListener(window, "load", function() {
      YAHOO.example.EnhanceFromMarkup = new function() {
      var sDefs = [
      {key:"a",label:"Bar,sortable:true},
      {label:"Stat", children: [
      {key:"b",label:"Rank",sortable:true},
      {key:"c",label:"Value",sortable:true}
      ]},
      {key:"d",label:"Games",sortable:true},
      {key:"e",label:"Team",sortable:true}
      ];
      this.sSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get
      ("table1"));
      this.sSource.responseType =
      YAHOO.util.DataSource.TYPE_HTMLTABLE;
      this.sSource.responseSchema = {
      fields: [
      {key:"a"},
      {key:"b",parser:YAHOO.util.DataSource.parseNumber},
      {key:"c", parser:YAHOO.util.DataSource.parseNumber},
      {key:"d", parser:YAHOO.util.DataSource.parseNumber},
      {key:"e"}
      ]
      };
      var oConfigs = {
      sorted:{key:"a",dir:"asc"},
      paginated:true,
      paginator: {
      rowsPerPage: 25,
      dropdownOptions: [25,50,100]
      }
      };

      this.sTable = new YAHOO.widget.DataTable("tablediv", sDefs,
      this.sSource,oConfigs);
      this.sTable.subscribe("rowMouseoverEvent",
      this.sTable.onEventHighlightRow);
      this.sTable.subscribe("rowMouseoutEvent",
      this.sTable.onEventUnhighlightRow);
      }
      });
      </script>
    • Satyam
      I used the code from the DataTable examples, the same you probably used as the basis for your code, since it has several coincidences (the root class is called
      Message 2 of 5 , Dec 31, 2007
        I used the code from the DataTable examples, the same you probably used as
        the basis for your code, since it has several coincidences (the root class
        is called YAHOO.example.EnhanceFromMarkup ) and added pagination to it and I
        can't reproduce your issue. Are you using YUI 2.3 or higher? Pagination
        was introduced shortly before that version and it had several issues in its
        first release, the one you found wouldn't surprise me in those versions, but
        it doesn't happen with 2.4.1, if the current page is beyond the total pages
        after the rows per page is changed, it will show the last page available.

        Satyam

        ----- Original Message -----
        From: "roallen2" <rallen@...>
        To: <ydn-javascript@yahoogroups.com>
        Sent: Monday, December 31, 2007 2:21 PM
        Subject: [ydn-javascript] Datatable Paginator: How to start on Page 1 after
        selecting new dropdownoption?


        >I have a table with 100 entries. I'm using Paginator with a default
        > rowsperpage set to 25 and dropdownoptions of 50 and 100. If someone
        > clicks on page 4 and then selects 50 or 100 from the dropdown, the
        > table shows "No records". You have to click on the page 1/2 links to
        > see any records. Is there a way to have the table start on Page 1
        > after someone selects from the drop down menu (using an inline table
        > as the data source)?
        >
        > My code is below. Thanks!
        >
        >
        > <script type="text/javascript">
        > YAHOO.util.Event.addListener(window, "load", function() {
        > YAHOO.example.EnhanceFromMarkup = new function() {
        > var sDefs = [
        > {key:"a",label:"Bar,sortable:true},
        > {label:"Stat", children: [
        > {key:"b",label:"Rank",sortable:true},
        > {key:"c",label:"Value",sortable:true}
        > ]},
        > {key:"d",label:"Games",sortable:true},
        > {key:"e",label:"Team",sortable:true}
        > ];
        > this.sSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get
        > ("table1"));
        > this.sSource.responseType =
        > YAHOO.util.DataSource.TYPE_HTMLTABLE;
        > this.sSource.responseSchema = {
        > fields: [
        > {key:"a"},
        > {key:"b",parser:YAHOO.util.DataSource.parseNumber},
        > {key:"c", parser:YAHOO.util.DataSource.parseNumber},
        > {key:"d", parser:YAHOO.util.DataSource.parseNumber},
        > {key:"e"}
        > ]
        > };
        > var oConfigs = {
        > sorted:{key:"a",dir:"asc"},
        > paginated:true,
        > paginator: {
        > rowsPerPage: 25,
        > dropdownOptions: [25,50,100]
        > }
        > };
        >
        > this.sTable = new YAHOO.widget.DataTable("tablediv", sDefs,
        > this.sSource,oConfigs);
        > this.sTable.subscribe("rowMouseoverEvent",
        > this.sTable.onEventHighlightRow);
        > this.sTable.subscribe("rowMouseoutEvent",
        > this.sTable.onEventUnhighlightRow);
        > }
        > });
        > </script>
        >
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        > --
        > No virus found in this incoming message.
        > Checked by AVG Free Edition.
        > Version: 7.5.516 / Virus Database: 269.17.12/1203 - Release Date:
        > 30/12/2007 11:27
        >
        >
      • roallen2
        Yes, I m using 2.3. I just verified it happens with both IE7 and Firefox. Here is an example:
        Message 3 of 5 , Dec 31, 2007
          Yes, I'm using 2.3. I just verified it happens with both IE7 and
          Firefox. Here is an example:

          http://statsheet.com/mcb/players/stats/minutes_avg?season=2007-2008

          Click the page "4" link and then select 100 from the dropdown.

          Robbie
        • Satyam
          I ve just run a diff in between 2.3.0 which is what you are using and 2.3.1 and one of the fixes in that version is the one you need. I thought the big fix on
          Message 4 of 5 , Dec 31, 2007
            I've just run a diff in between 2.3.0 which is what you are using and 2.3.1
            and one of the fixes in that version is the one you need. I thought the big
            fix on the paginator had been from 2.2 to 2.3, but it was not until 2.3.1.

            If you do a diff in between those, you'll see the patch on lines 4930 of
            datatable-beta.js 2.3.1 which would fit into lines 4725 of version 2.3.0.

            Satyam
            ----- Original Message -----
            From: "roallen2" <rallen@...>
            To: <ydn-javascript@yahoogroups.com>
            Sent: Monday, December 31, 2007 3:33 PM
            Subject: [ydn-javascript] Re: Datatable Paginator: How to start on Page 1
            after selecting new dropdownoption?


            > Yes, I'm using 2.3. I just verified it happens with both IE7 and
            > Firefox. Here is an example:
            >
            > http://statsheet.com/mcb/players/stats/minutes_avg?season=2007-2008
            >
            > Click the page "4" link and then select 100 from the dropdown.
            >
            > Robbie
            >
            >
            >
            >
            >
            > Yahoo! Groups Links
            >
            >
            >
            >
            >
            > --
            > No virus found in this incoming message.
            > Checked by AVG Free Edition.
            > Version: 7.5.516 / Virus Database: 269.17.12/1203 - Release Date:
            > 30/12/2007 11:27
            >
            >
          • roallen2
            ... of ... 2.3.0. Worked like a charm. Thanks!
            Message 5 of 5 , Jan 2, 2008
              > If you do a diff in between those, you'll see the patch on lines 4930
              of
              > datatable-beta.js 2.3.1 which would fit into lines 4725 of version
              2.3.0.

              Worked like a charm. Thanks!
            Your message has been successfully submitted and would be delivered to recipients shortly.