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

Problem extending the Paginator widget

Expand Messages
  • hejwoszmichael@ymail.com
    Hello! Based on one of Satyam s articles (available here: http://satyam.com.ar/yui/ and highly recommended), I have extended the Paginator widget. My problem
    Message 1 of 2 , Mar 2, 2009
    View Source
    • 0 Attachment
      Hello!

      Based on one of Satyam's articles (available here:
      http://satyam.com.ar/yui/ and highly recommended), I have extended the
      Paginator widget.

      My problem is that the option defined in an object passed to
      constructor are ignored (specifically the <strong>containers</strong>
      config attribute).

      Does anyone have a clue?

      The code looks as follows:

      Snippet #1:
      oNewDTCfg = {
      paginator: new VC.Paginator({
      containers: "newPagContainer"
      })
      },
      oNewDT = new VC.DataTable(
      "newDTContainer",
      aDTColDefs,
      oNewDS,
      oNewDTCfg
      );

      Snippet #2: The extended Paginator widget
      var VC = YAHOO.namespace("vc");

      (function() {
      var lang = YAHOO.lang,
      Pag = YAHOO.widget.Paginator;

      VC.Paginator = function(oConfigs) {
      oConfigs = oConfigs || {};
      oConfigs.containers = oConfigs.containers || null;
      oConfigs.rowsPerPage = 5;
      oConfigs.template = "{CurrentPageReport}" + Pag.TEMPLATE_ROWS_PER_PAGE;
      oConfigs.alwaysVisible = false;
      oConfigs.pageReportTemplate = "<strong>{start}</strong> -
      <strong>{end}</strong> spośród <strong>{total}</strong> egzemplarzy";
      oConfigs.pageReportValueGenerator = function(paginator) {
      var aPgRecs = paginator.getPageRecords(),
      iTotalRecs = paginator.getTotalRecords();

      return {
      start: aPgRecs[0] + 1,
      end: aPgRecs[1]+ 1,
      total: iTotalRecs
      };
      };
      oConfigs.firstPageLinkLabel = "<<";
      oConfigs.lastPageLinkLabel = ">>";
      oConfigs.nextPageLinkLabel = ">";
      oConfigs.previousPageLinkLabel = "<";
      oConfigs.rowsPerPageOptions = [
      5,
      10,
      20,
      30,
      50,
      {
      value: "all",
      text: "Wszystkie"
      }
      ];

      VC.Paginator.superclass.constructor.call(this, oConfigs);
      }

      lang.extend(VC.Paginator, Pag);
      })();

      YAHOO.register("vcPaginator", VC.Paginator, {version: "0.1", build: "1"});
    • Lucas Smith
      ... Pag.TEMPLATE_ROWS_PER_PAGE; ... egzemplarzy ; ... 1 }); ... Since you re not adding or modifying any behavior of the Paginator class, it looks like a
      Message 2 of 2 , Mar 2, 2009
      View Source
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "hejwoszmichael@..."
        <hejwoszmichael@...> wrote:
        >
        > Hello!
        >
        > Based on one of Satyam's articles (available here:
        > http://satyam.com.ar/yui/ and highly recommended), I have extended the
        > Paginator widget.
        >
        > My problem is that the option defined in an object passed to
        > constructor are ignored (specifically the <strong>containers</strong>
        > config attribute).
        >
        > Does anyone have a clue?
        >
        > The code looks as follows:
        >
        > Snippet #1:
        > oNewDTCfg = {
        > paginator: new VC.Paginator({
        > containers: "newPagContainer"
        > })
        > },
        > oNewDT = new VC.DataTable(
        > "newDTContainer",
        > aDTColDefs,
        > oNewDS,
        > oNewDTCfg
        > );
        >
        > Snippet #2: The extended Paginator widget
        > var VC = YAHOO.namespace("vc");
        >
        > (function() {
        > var lang = YAHOO.lang,
        > Pag = YAHOO.widget.Paginator;
        >
        > VC.Paginator = function(oConfigs) {
        > oConfigs = oConfigs || {};
        > oConfigs.containers = oConfigs.containers || null;
        > oConfigs.rowsPerPage = 5;
        > oConfigs.template = "{CurrentPageReport}" +
        Pag.TEMPLATE_ROWS_PER_PAGE;
        > oConfigs.alwaysVisible = false;
        > oConfigs.pageReportTemplate = "<strong>{start}</strong> -
        > <strong>{end}</strong> spośród <strong>{total}</strong>
        egzemplarzy";
        > oConfigs.pageReportValueGenerator = function(paginator) {
        > var aPgRecs = paginator.getPageRecords(),
        > iTotalRecs = paginator.getTotalRecords();
        >
        > return {
        > start: aPgRecs[0] + 1,
        > end: aPgRecs[1]+ 1,
        > total: iTotalRecs
        > };
        > };
        > oConfigs.firstPageLinkLabel = "<<";
        > oConfigs.lastPageLinkLabel = ">>";
        > oConfigs.nextPageLinkLabel = ">";
        > oConfigs.previousPageLinkLabel = "<";
        > oConfigs.rowsPerPageOptions = [
        > 5,
        > 10,
        > 20,
        > 30,
        > 50,
        > {
        > value: "all",
        > text: "Wszystkie"
        > }
        > ];
        >
        > VC.Paginator.superclass.constructor.call(this, oConfigs);
        > }
        >
        > lang.extend(VC.Paginator, Pag);
        > })();
        >
        > YAHOO.register("vcPaginator", VC.Paginator, {version: "0.1", build:
        "1"});
        >

        Since you're not adding or modifying any behavior of the Paginator
        class, it looks like a better fit for you would be a factory function.
        Give this a try: http://gist.github.com/73198

        Hope this helps,
        Luke
      Your message has been successfully submitted and would be delivered to recipients shortly.