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

Re: [ydn-javascript] How to refresh an XML dataset

Expand Messages
  • Satyam
    This method added to DataTable should be able to reload the new data: YAHOO.widget.DataTable.prototype.requery = function(newRequest) {
    Message 1 of 10 , Jul 23, 2008
    View Source
    • 0 Attachment
      This method added to DataTable should be able to reload the new data:

      YAHOO.widget.DataTable.prototype.requery = function(newRequest) {
      this.getDataSource().sendRequest(
      (newRequest === undefined?this.get('initialRequest'):newRequest),
      this.onDataReturnInitializeTable,
      this
      );
      };

      It will reuse the same DataSource and if not provided with a newRequest
      argument, it will repeat the same request as the original one.

      Satyam


      Stuart Grimshaw wrote:
      > I've got a dataset object, attached to a datatable, that I create from
      > XML, like this:
      >
      > var dataSet = new YAHOO.util.DataSource(xml);
      > dataSet.responseType = YAHOO.util.DataSource.TYPE_XML;
      > dataSet.responseSchema = {
      > fields: fieldDefs,
      > resultNode: 'Row'
      > };
      >
      > If I want to update the table with a request to the server, what's the
      > best way to update the data in the data in the dataset?
      >
      > -S
      >
      >
      > ------------------------------------
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      > No virus found in this incoming message.
      > Checked by AVG - http://www.avg.com
      > Version: 8.0.138 / Virus Database: 270.5.4/1566 - Release Date: 22/07/2008 6:00
      >
      >
      >
      >
    • Stuart Grimshaw
      ... The original datasource is just an XML string though, so there is no URL to append the request to. The datasource is created with a string because we use
      Message 2 of 10 , Jul 23, 2008
      View Source
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
        >
        > This method added to DataTable should be able to reload the new data:
        >
        > YAHOO.widget.DataTable.prototype.requery = function(newRequest) {
        > this.getDataSource().sendRequest(
        > (newRequest === undefined?this.get('initialRequest'):newRequest),
        > this.onDataReturnInitializeTable,
        > this
        > );
        > };
        >
        > It will reuse the same DataSource and if not provided with a newRequest
        > argument, it will repeat the same request as the original one.

        The original datasource is just an XML string though, so there is no
        URL to append the request to.

        The datasource is created with a string because we use the same XML to
        render dialog boxes and other UI elements as well as datatables.

        Is there any way to feed it another XML string and have it digest that
        instead? I was looking at parseXMLdata as a way to do what I want.

        Failing that, could I swap out the dataset for a new one without too
        much pain?

        -S
      • Satyam
        The xml string would be stored into the liveData property of DataSource: http://developer.yahoo.com/yui/docs/YAHOO.util.DataSource.html#property_liveData So,
        Message 3 of 10 , Jul 23, 2008
        View Source
        • 0 Attachment
          The xml string would be stored into the liveData property of DataSource:

          http://developer.yahoo.com/yui/docs/YAHOO.util.DataSource.html#property_liveData

          So, for you it would be something like:

          var ds = myDataTable.getDataSource();
          ds.liveData = newXmlData;
          ds.sendRequest('', this.onDataReturnInitializeTable, this );

          or close to that.

          Satyam


          Stuart Grimshaw wrote:
          > --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
          >
          >> This method added to DataTable should be able to reload the new data:
          >>
          >> YAHOO.widget.DataTable.prototype.requery = function(newRequest) {
          >> this.getDataSource().sendRequest(
          >> (newRequest === undefined?this.get('initialRequest'):newRequest),
          >> this.onDataReturnInitializeTable,
          >> this
          >> );
          >> };
          >>
          >> It will reuse the same DataSource and if not provided with a newRequest
          >> argument, it will repeat the same request as the original one.
          >>
          >
          > The original datasource is just an XML string though, so there is no
          > URL to append the request to.
          >
          > The datasource is created with a string because we use the same XML to
          > render dialog boxes and other UI elements as well as datatables.
          >
          > Is there any way to feed it another XML string and have it digest that
          > instead? I was looking at parseXMLdata as a way to do what I want.
          >
          > Failing that, could I swap out the dataset for a new one without too
          > much pain?
          >
          > -S
          >
          >
          > ------------------------------------
          >
          > Yahoo! Groups Links
          >
          >
          >
          >
          > No virus found in this incoming message.
          > Checked by AVG - http://www.avg.com
          > Version: 8.0.138 / Virus Database: 270.5.4/1566 - Release Date: 22/07/2008 6:00
          >
          >
          >
          >
        • Stuart Grimshaw
          ... http://developer.yahoo.com/yui/docs/YAHOO.util.DataSource.html#property_liveData ... Thanks Satyam, that was spot on. The new xml also removes columns from
          Message 4 of 10 , Jul 23, 2008
          View Source
          • 0 Attachment
            --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
            >
            > The xml string would be stored into the liveData property of DataSource:
            >
            >
            http://developer.yahoo.com/yui/docs/YAHOO.util.DataSource.html#property_liveData
            >
            > So, for you it would be something like:
            >
            > var ds = myDataTable.getDataSource();
            > ds.liveData = newXmlData;
            > ds.sendRequest('', this.onDataReturnInitializeTable, this );
            >
            > or close to that.

            Thanks Satyam, that was spot on. The new xml also removes columns from
            the data too (I'm implementing a "Personalize" option for a table, so
            people can switch colums on/off)

            Should I be able to change the columns, like this:

            var xml = oRequest.responseXML;
            var metaData = this.getMetaData(xml);
            var ds = this.dataTable.getDataSource();
            ds.responseSchema = {
            fields: metaData.fieldDefs,
            resultNode: 'Row'
            };
            ds.liveData = xml;

            ds.sendRequest('', this.dataTable.onDataReturnInitializeTable,
            this.dataTable);
            Sdl.Web.Widgets.DialogManager.wait.hide();
            this.dataTable.render();

            The data is no longer displayed, but if I remove a column, it stays in
            the table, and if I add one, it does not get displayed at all.

            -S
          • Satyam
            The DataSource does not control what gets shown and what doesn t. You can actually list in the fields array all the fields that could ever possibly be read,
            Message 5 of 10 , Jul 23, 2008
            View Source
            • 0 Attachment
              The DataSource does not control what gets shown and what doesn't. You
              can actually list in the fields array all the fields that could ever
              possibly be read, the DataSource will simply set to null all those that
              didn't come in a particular transmission. This will not affect what
              gets shown and what doesn't. It is the columns definition in the
              DataTable that tells what to show. You can use DataTable
              insertColumn/removeColumn or showColumn/hideColumn to handle visibility.

              Satyam


              Stuart Grimshaw wrote:
              > --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
              >
              >> The xml string would be stored into the liveData property of DataSource:
              >>
              >>
              >>
              > http://developer.yahoo.com/yui/docs/YAHOO.util.DataSource.html#property_liveData
              >
              >> So, for you it would be something like:
              >>
              >> var ds = myDataTable.getDataSource();
              >> ds.liveData = newXmlData;
              >> ds.sendRequest('', this.onDataReturnInitializeTable, this );
              >>
              >> or close to that.
              >>
              >
              > Thanks Satyam, that was spot on. The new xml also removes columns from
              > the data too (I'm implementing a "Personalize" option for a table, so
              > people can switch colums on/off)
              >
              > Should I be able to change the columns, like this:
              >
              > var xml = oRequest.responseXML;
              > var metaData = this.getMetaData(xml);
              > var ds = this.dataTable.getDataSource();
              > ds.responseSchema = {
              > fields: metaData.fieldDefs,
              > resultNode: 'Row'
              > };
              > ds.liveData = xml;
              >
              > ds.sendRequest('', this.dataTable.onDataReturnInitializeTable,
              > this.dataTable);
              > Sdl.Web.Widgets.DialogManager.wait.hide();
              > this.dataTable.render();
              >
              > The data is no longer displayed, but if I remove a column, it stays in
              > the table, and if I add one, it does not get displayed at all.
              >
              > -S
              >
              >
              > ------------------------------------
              >
              > Yahoo! Groups Links
              >
              >
              >
              >
              > No virus found in this incoming message.
              > Checked by AVG - http://www.avg.com
              > Version: 8.0.138 / Virus Database: 270.5.4/1566 - Release Date: 22/07/2008 6:00
              >
              >
              >
              >
            • Stuart Grimshaw
              ... Here s what I ended up with. http://pastie.org/240947 It loads the new data into the dataset, retrieves meta data from the same xml and adds/removes
              Message 6 of 10 , Jul 25, 2008
              View Source
              • 0 Attachment
                --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
                >
                > The DataSource does not control what gets shown and what doesn't. You
                > can actually list in the fields array all the fields that could ever
                > possibly be read, the DataSource will simply set to null all those that
                > didn't come in a particular transmission. This will not affect what
                > gets shown and what doesn't. It is the columns definition in the
                > DataTable that tells what to show. You can use DataTable
                > insertColumn/removeColumn or showColumn/hideColumn to handle visibility.

                Here's what I ended up with.

                http://pastie.org/240947

                It loads the new data into the dataset, retrieves meta data from the
                same xml and adds/removes columns, adjusts the column widths according
                to those calculated in the metadata and finally redraws the table to
                display it all.
              • Caxton
                Dear Satyam: Thanks for the requery method which avoids to refresh entire datatable. However, I am confused that this method is only sensitive on firefox but
                Message 7 of 10 , Mar 4, 2009
                View Source
                • 0 Attachment
                  Dear Satyam:

                  Thanks for the requery method which avoids to refresh entire datatable.

                  However, I am confused that this method is only sensitive on firefox but not IE(ver.7) and Chrome?

                  Strangely, the requery method will trigger after two actions in IE. For example, I add a new data and push the "ADD" button, nothing change on datatable; I add another data and the previous added data will show up. Well, the second added data will show up after the third data added.

                  I have try to call requery() many times while button click, but the result is the same.

                  Any suggestions would be greatly appreciated. Thanks.

                  Caxton.

                  --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
                  >
                  > This method added to DataTable should be able to reload the new data:
                  >
                  > YAHOO.widget.DataTable.prototype.requery = function(newRequest) {
                  > this.getDataSource().sendRequest(
                  > (newRequest === undefined?this.get('initialRequest'):newRequest),
                  > this.onDataReturnInitializeTable,
                  > this
                  > );
                  > };
                  >
                  > It will reuse the same DataSource and if not provided with a newRequest
                  > argument, it will repeat the same request as the original one.
                  >
                  > Satyam
                • Satyam
                  Might it be related to IE s excesive caching? I don t know how Chrome behaves in this area, but the two main reasons why something doesn t work in IE but does
                  Message 8 of 10 , Mar 6, 2009
                  View Source
                  • 0 Attachment
                    Might it be related to IE's excesive caching? I don't know how Chrome
                    behaves in this area, but the two main reasons why something doesn't
                    work in IE but does in every other are a) an trailing comma in an array
                    and b) too much caching. Are you sending the right headers from the
                    server to prevent caching?

                    Satyam

                    Caxton escribió:
                    > Dear Satyam:
                    >
                    > Thanks for the requery method which avoids to refresh entire datatable.
                    >
                    > However, I am confused that this method is only sensitive on firefox but not IE(ver.7) and Chrome?
                    >
                    > Strangely, the requery method will trigger after two actions in IE. For example, I add a new data and push the "ADD" button, nothing change on datatable; I add another data and the previous added data will show up. Well, the second added data will show up after the third data added.
                    >
                    > I have try to call requery() many times while button click, but the result is the same.
                    >
                    > Any suggestions would be greatly appreciated. Thanks.
                    >
                    > Caxton.
                    >
                    > --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
                    >
                    >> This method added to DataTable should be able to reload the new data:
                    >>
                    >> YAHOO.widget.DataTable.prototype.requery = function(newRequest) {
                    >> this.getDataSource().sendRequest(
                    >> (newRequest === undefined?this.get('initialRequest'):newRequest),
                    >> this.onDataReturnInitializeTable,
                    >> this
                    >> );
                    >> };
                    >>
                    >> It will reuse the same DataSource and if not provided with a newRequest
                    >> argument, it will repeat the same request as the original one.
                    >>
                    >> Satyam
                    >>
                    >
                    >
                    >
                    > ------------------------------------
                    >
                    > Yahoo! Groups Links
                    >
                    >
                    >
                    > ------------------------------------------------------------------------
                    >
                    >
                    > No virus found in this incoming message.
                    > Checked by AVG - www.avg.com
                    > Version: 8.0.237 / Virus Database: 270.11.7/1983 - Release Date: 03/04/09 07:41:00
                    >
                    >
                  • Caxton
                    Dear Satyam: I found that this method refreshs datatable but not paginator. The paginator will get no record after requery. How to modify this method in order
                    Message 9 of 10 , Jun 17, 2009
                    View Source
                    • 0 Attachment
                      Dear Satyam:

                      I found that this method refreshs datatable but not paginator.
                      The paginator will get no record after requery.
                      How to modify this method in order to refresh paginator also?
                      Thanks.

                      Caxton

                      --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
                      >
                      > This method added to DataTable should be able to reload the new data:
                      >
                      > YAHOO.widget.DataTable.prototype.requery = function(newRequest) {
                      > this.getDataSource().sendRequest(
                      > (newRequest === undefined?this.get('initialRequest'):newRequest),
                      > this.onDataReturnInitializeTable,
                      > this
                      > );
                      > };
                      >
                      > It will reuse the same DataSource and if not provided with a newRequest
                      > argument, it will repeat the same request as the original one.
                      >
                      > Satyam
                      >
                      >
                      > Stuart Grimshaw wrote:
                      > > I've got a dataset object, attached to a datatable, that I create from
                      > > XML, like this:
                      > >
                      > > var dataSet = new YAHOO.util.DataSource(xml);
                      > > dataSet.responseType = YAHOO.util.DataSource.TYPE_XML;
                      > > dataSet.responseSchema = {
                      > > fields: fieldDefs,
                      > > resultNode: 'Row'
                      > > };
                      > >
                      > > If I want to update the table with a request to the server, what's the
                      > > best way to update the data in the data in the dataset?
                      > >
                      > > -S
                      > >
                      > >
                      > > ------------------------------------
                      > >
                      > > Yahoo! Groups Links
                      > >
                      > >
                      > >
                      > >
                      > > No virus found in this incoming message.
                      > > Checked by AVG - http://www.avg.com
                      > > Version: 8.0.138 / Virus Database: 270.5.4/1566 - Release Date: 22/07/2008 6:00
                      > >
                      > >
                      > >
                      > >
                      >
                    Your message has been successfully submitted and would be delivered to recipients shortly.