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

Re: DataTable pagination issue (YUI version 2.5.0)

Expand Messages
  • y_lsmith
    Amir, Version 2.5.1 of DataSource introduced the metaFields collection. In version 2.5.0, the totalRecords identifier hangs directly off of the responseSchema
    Message 1 of 10 , May 1, 2008
      Amir,

      Version 2.5.1 of DataSource introduced the metaFields collection. In
      version 2.5.0, the totalRecords identifier hangs directly off of the
      responseSchema object. Try
      SENRO.clientsearch.myDataSource.responseSchema = {
      resultsList: 'records',
      fields: getResponseSchemaFields(SENRO.clientsearch.columnDefs),
      totalRecords: 'totalRecords'
      };

      Note paginationRecordOffset and other magic meta were also introduced
      in 2.5.1 as well.

      Hope this helps,
      Luke

      --- In ydn-javascript@yahoogroups.com, "amirlaher" <amirlaher@...> wrote:
      >
      > Hi there,
      >
      > The DataTable is a beautiful thing, but I've had one issue with it...
      >
      > I've got serverside pagination working, but for some reason the
      > totalRecords wasn't being recognised without a hack. For some reason
      > it uses the recordsReturned value in place of totalRecords.
      >
      > ::: My responseSchema looks like this:
      > SENRO.clientsearch.myDataSource.responseSchema = {
      > resultsList: 'records',
      > fields:
      getResponseSchemaFields(SENRO.clientsearch.columnDefs),
      > metaFields : {
      > totalRecords: 'totalRecords',
      > paginationRecordOffset : "startIndex"
      > }
      > };
      >
      > ::: My server's JSON results look like this:
      >
      {"recordsReturned":300,"totalRecords":5222,"startIndex":0,"sort":null,"dir":"asc"","records":[{"status":"1",
      > ....
      > }
      >
      > ** My config looks like this
      > SENRO.clientsearch.configs = {
      > initialRequest : initRequest,
      > generateRequest : SENRO.clientsearch.buildQueryString,
      > paginator: new YAHOO.widget.Paginator({
      > rowsPerPage : 20,
      > template: "{FirstPageLink} {PreviousPageLink} {PageLinks}
      > {NextPageLink} {LastPageLink} {CurrentPageReport}",
      > pageReportTemplate : "Showing items {startIndex} - {endIndex} of
      > {totalRecords}",
      > totalRecords: SENRO.clientsearch.resultcount,
      >
      > }),
      > renderLoopSize : 20,
      > scrollable: false,
      > paginated: true,
      > // paginationEventHandler :
      > SENRO.clientsearch.handlePagination,
      > paginationEventHandler :
      > YAHOO.widget.DataTable.handleDataSourcePagination,
      > recordOffset: 0
      > };
      >
      > I haven't posted the whole of the code because it's not for public
      > consumption, let me know if you need more info.
      >
      > The hack I used to fix it was to store the totalRecords amount
      > separately in the page, and hack together a different
      > paginationEventHandler.
      > I copied and pasted the handleSimplePagination and
      > handleDataSourcePagination functions straight out of
      > datatable-beta-debug.js, and hard-coded the totalRecords value into my
      > modified handleSimplePagination function.
      >
      > I can live with this, but it's not ideal. I can't really figure out
      > what's wrong with my setup that it's not taking note of my
      > totalRecords value. Is this a known issue?
      >
      > Cheers,
      >
      > Amir
      >
    • amirlaher
      Aha! That clears up a lot of confusion - thanks Luke. This works beautifully. I ve been reading the current documents (relating to 2.5.1), and didn t realise
      Message 2 of 10 , May 2, 2008
        Aha! That clears up a lot of confusion - thanks Luke.
        This works beautifully.
        I've been reading the current documents (relating to 2.5.1), and didn't
        realise the differences in the specifications. I guess it's still in
        beta, so fair enough
        I will try to upgrade to 2.5.1 as soon as.
        Thanks very much,
        Amir

        --- In ydn-javascript@yahoogroups.com, "y_lsmith" <lsmith@...> wrote:
        >
        > Amir,
        >
        > Version 2.5.1 of DataSource introduced the metaFields collection. In
        > version 2.5.0, the totalRecords identifier hangs directly off of the
        > responseSchema object. Try
        > SENRO.clientsearch.myDataSource.responseSchema = {
        > resultsList: 'records',
        > fields: getResponseSchemaFields(SENRO.clientsearch.columnDefs),
        > totalRecords: 'totalRecords'
        > };
        >
        > Note paginationRecordOffset and other magic meta were also introduced
        > in 2.5.1 as well.
        >
        > Hope this helps,
        > Luke
        >
        > --- In ydn-javascript@yahoogroups.com, "amirlaher" amirlaher@ wrote:
        > >
        > > Hi there,
        > >
        > > The DataTable is a beautiful thing, but I've had one issue with
        it...
        > >
        > > I've got serverside pagination working, but for some reason the
        > > totalRecords wasn't being recognised without a hack. For some reason
        > > it uses the recordsReturned value in place of totalRecords.
        > >
        > > ::: My responseSchema looks like this:
        > > SENRO.clientsearch.myDataSource.responseSchema = {
        > > resultsList: 'records',
        > > fields:
        > getResponseSchemaFields(SENRO.clientsearch.columnDefs),
        > > metaFields : {
        > > totalRecords: 'totalRecords',
        > > paginationRecordOffset : "startIndex"
        > > }
        > > };
        > >
        > > ::: My server's JSON results look like this:
        > >
        >
        {"recordsReturned":300,"totalRecords":5222,"startIndex":0,"sort":null,"d\
        ir":"asc"","records":[{"status":"1",
        > > ....
        > > }
        > >
        > > ** My config looks like this
        > > SENRO.clientsearch.configs = {
        > > initialRequest : initRequest,
        > > generateRequest : SENRO.clientsearch.buildQueryString,
        > > paginator: new YAHOO.widget.Paginator({
        > > rowsPerPage : 20,
        > > template: "{FirstPageLink} {PreviousPageLink} {PageLinks}
        > > {NextPageLink} {LastPageLink} {CurrentPageReport}",
        > > pageReportTemplate : "Showing items {startIndex} - {endIndex}
        of
        > > {totalRecords}",
        > > totalRecords: SENRO.clientsearch.resultcount,
        > >
        > > }),
        > > renderLoopSize : 20,
        > > scrollable: false,
        > > paginated: true,
        > > // paginationEventHandler :
        > > SENRO.clientsearch.handlePagination,
        > > paginationEventHandler :
        > > YAHOO.widget.DataTable.handleDataSourcePagination,
        > > recordOffset: 0
        > > };
        > >
        > > I haven't posted the whole of the code because it's not for public
        > > consumption, let me know if you need more info.
        > >
        > > The hack I used to fix it was to store the totalRecords amount
        > > separately in the page, and hack together a different
        > > paginationEventHandler.
        > > I copied and pasted the handleSimplePagination and
        > > handleDataSourcePagination functions straight out of
        > > datatable-beta-debug.js, and hard-coded the totalRecords value into
        my
        > > modified handleSimplePagination function.
        > >
        > > I can live with this, but it's not ideal. I can't really figure out
        > > what's wrong with my setup that it's not taking note of my
        > > totalRecords value. Is this a known issue?
        > >
        > > Cheers,
        > >
        > > Amir
        > >
        >
      • amirlaher
        Cool, I ve left those quotes in. The problem was elsewhere anyway (see Luke s response on this topic) I m actually using Zend_Json to generate the JSON from
        Message 3 of 10 , May 2, 2008
          Cool, I've left those quotes in. The problem was elsewhere anyway (see
          Luke's response on this topic)

          I'm actually using Zend_Json to generate the JSON from php, so I
          really didn't want to hack at it, and I'm relieved to hear you say
          it's more compliant this way anyway

          Cheers,

          Amir


          --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@...> wrote:
          >
          > Actually, you might do worse by taking those quotes out. If you
          include the
          > json component, the DataSource will use it and that one does expect the
          > property names to be enclosed in quotes, which is what the standard
          says.
          > If you don't include YUI's JSON component, the original parser in the
          > DataSource will tolerate those absent quotes.
          >
          > Satyam
          >
          >
          >
          > ----- Original Message -----
          > From: "bretlevy" <bret@...>
          > To: <ydn-javascript@yahoogroups.com>
          > Sent: Thursday, May 01, 2008 6:05 PM
          > Subject: [ydn-javascript] Re: DataTable pagination issue (YUI
          version 2.5.0)
          >
          >
          > >
          > > Amir:
          > >
          > > Can you try taking the quotes off the object literals in your
          > > returned JSON? You said you return this:
          > >
          > > {"recordsReturned":300,"totalRecords":5222,"startIndex":0,"sort":null,
          > > "dir":"asc"","records":[{"status":"1",...
          > >
          > > Try:
          > >
          > > {recordsReturned:300,totalRecords:5222,startIndex:0,sort:null,dir:"asc
          > > ",records:[{status:"1",...
          > >
          > > I also notice you have an extra quote (") after the "asc" value.
          > > This might solve your problem.
          > >
          > > Hope it helps...
          > >
          > > ~~bret
          > >
          > >
          > >
          > > --- In ydn-javascript@yahoogroups.com, "amirlaher" <amirlaher@>
          > > wrote:
          > >>
          > >> Hi there,
          > >>
          > >> The DataTable is a beautiful thing, but I've had one issue with
          > > it...
          > >>
          > >> I've got serverside pagination working, but for some reason the
          > >> totalRecords wasn't being recognised without a hack. For some reason
          > >> it uses the recordsReturned value in place of totalRecords.
          > >>
          > >> ::: My responseSchema looks like this:
          > >> SENRO.clientsearch.myDataSource.responseSchema = {
          > >> resultsList: 'records',
          > >> fields: getResponseSchemaFields
          > > (SENRO.clientsearch.columnDefs),
          > >> metaFields : {
          > >> totalRecords: 'totalRecords',
          > >> paginationRecordOffset : "startIndex"
          > >> }
          > >> };
          > >>
          > >> ::: My server's JSON results look like this:
          > >>
          > > {"recordsReturned":300,"totalRecords":5222,"startIndex":0,"sort":null,
          > > "dir":"asc"","records":[{"status":"1",
          > >> ....
          > >> }
          > >>
          > >> ** My config looks like this
          > >> SENRO.clientsearch.configs = {
          > >> initialRequest : initRequest,
          > >> generateRequest :
          > > SENRO.clientsearch.buildQueryString,
          > >> paginator: new YAHOO.widget.Paginator
          > > ({
          > >> rowsPerPage : 20,
          > >> template: "{FirstPageLink}
          > > {PreviousPageLink} {PageLinks}
          > >> {NextPageLink} {LastPageLink} {CurrentPageReport}",
          > >> pageReportTemplate : "Showing
          > > items {startIndex} - {endIndex} of
          > >> {totalRecords}",
          > >> totalRecords:
          > > SENRO.clientsearch.resultcount,
          > >>
          > >> }),
          > >> renderLoopSize : 20,
          > >> scrollable: false,
          > >> paginated: true,
          > >> // paginationEventHandler :
          > >> SENRO.clientsearch.handlePagination,
          > >> paginationEventHandler :
          > >> YAHOO.widget.DataTable.handleDataSourcePagination,
          > >> recordOffset: 0
          > >> };
          > >>
          > >> I haven't posted the whole of the code because it's not for public
          > >> consumption, let me know if you need more info.
          > >>
          > >> The hack I used to fix it was to store the totalRecords amount
          > >> separately in the page, and hack together a different
          > >> paginationEventHandler.
          > >> I copied and pasted the handleSimplePagination and
          > >> handleDataSourcePagination functions straight out of
          > >> datatable-beta-debug.js, and hard-coded the totalRecords value into
          > > my
          > >> modified handleSimplePagination function.
          > >>
          > >> I can live with this, but it's not ideal. I can't really figure out
          > >> what's wrong with my setup that it's not taking note of my
          > >> totalRecords value. Is this a known issue?
          > >>
          > >> Cheers,
          > >>
          > >> Amir
          > >>
          > >
          > >
          > >
          > > ------------------------------------
          > >
          > > Yahoo! Groups Links
          > >
          > >
          > >
          > >
          > >
          > > --
          > > No virus found in this incoming message.
          > > Checked by AVG.
          > > Version: 7.5.524 / Virus Database: 269.23.7/1408 - Release Date:
          > > 30/04/2008 18:10
          > >
          > >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.