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

Re: 2 Datatables 1 Datasource

Expand Messages
  • hifire81
    Satyam, That s a good idea for the first request, but what if I want to enable polling? If I create a new datatable object every poll, the whole table gets
    Message 1 of 6 , Jun 2, 2008
    • 0 Attachment
      Satyam,

      That's a good idea for the first request, but what if I want to enable
      polling? If I create a new datatable object every poll, the whole
      table gets redrawn and that looks bad.

      If I enable polling and set the initial request to a JS_ARRAY, will it
      look in the same array instance on subsequent polls?

      -JD

      --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@...> wrote:
      >
      > You could setup one DataTable with its DataSource pointing to the
      remote
      > source of that. You could override any of the doBeforeXXX functions in
      > DataSource or listen to one of the response events (I don't recall
      which one
      > provides you the data already parsed). You can get the parsed data
      received
      > for the initial table in any of those functions/events and use that to
      > create the second table with its own DataSource set to a JS_ARRAY
      response
      > type. Remember that in the doBeforeXXX functions you have to return
      the
      > last argument received.
      >
      > Satyam
      >
      >
      >
      > ----- Original Message -----
      > From: "hifire81" <hifire@...>
      > To: <ydn-javascript@yahoogroups.com>
      > Sent: Friday, May 23, 2008 10:58 PM
      > Subject: [ydn-javascript] 2 Datatables 1 Datasource
      >
      >
      > > Hi All,
      > >
      > > I have a page outputting a json string that I would like to use to
      > > populate two data tables (to reduce requests to the server).
      > >
      > > I see that you can specify where to look in the data with the response
      > > schema and for one datatable that works. If I initialize one
      > > datasource, set the responseSchema, pass it to a datatable, modify the
      > > response schema and send it to another datatable, I would think that
      > > would wreck the data for the first table.
      > >
      > > I guess it makes more sense to do things manually. Set up my own
      > > timer, get the json string and update two datasources with a JSARRAY
      > > created from subsets of the json string. I haven't been able to figure
      > > out how to update a datasource with a JSARRAY. Do I want to do that
      > > with sendRequest somehow?
      > >
      > > TIA
      > >
      > > -JD
      > >
      > >
      > > ------------------------------------
      > >
      > > Yahoo! Groups Links
      > >
      > >
      > >
      >
      >
      >
      --------------------------------------------------------------------------------
      >
      >
      >
      > No virus found in this incoming message.
      > Checked by AVG.
      > Version: 8.0.100 / Virus Database: 269.24.1/1463 - Release Date:
      23/05/2008
      > 15:36
      >
    • Satyam
      Jd, sorry for the delay, been out of town. Polling, ok, that s a different story then. What I would do is to create the two datatables with any sort of
      Message 2 of 6 , Jun 5, 2008
      • 0 Attachment
        Jd,

        sorry for the delay, been out of town. Polling, ok, that's a different
        story then.

        What I would do is to create the two datatables with any sort of DataSources
        with empty local data. Type JS_ARRAY would be the easiest. You can use the
        initialLoad configuration attribute so that it doesn't even try to load
        anything from those. You can proibably manage with just one DataSource for
        both since, preventing the initialLoad of data, they won't be called anyway.

        Then create an extra DataSources which will be remote, pointing to the
        actual source of data. You can use DataSource method setInterval for the
        polling:
        http://developer.yahoo.com/yui/datasource/#polling

        You should provide a function of your own as the callback in the call to
        setInterval. In that function, you would call the methods to fill up each
        of the DataTables with the data just received:

        http://developer.yahoo.com/yui/datasource/#hooking

        Satyam



        ----- Original Message -----
        From: "hifire81" <hifire@...>
        To: <ydn-javascript@yahoogroups.com>
        Sent: Monday, June 02, 2008 5:04 PM
        Subject: [ydn-javascript] Re: 2 Datatables 1 Datasource


        > Satyam,
        >
        > That's a good idea for the first request, but what if I want to enable
        > polling? If I create a new datatable object every poll, the whole
        > table gets redrawn and that looks bad.
        >
        > If I enable polling and set the initial request to a JS_ARRAY, will it
        > look in the same array instance on subsequent polls?
        >
        > -JD
        >
        > --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@...> wrote:
        >>
        >> You could setup one DataTable with its DataSource pointing to the
        > remote
        >> source of that. You could override any of the doBeforeXXX functions in
        >> DataSource or listen to one of the response events (I don't recall
        > which one
        >> provides you the data already parsed). You can get the parsed data
        > received
        >> for the initial table in any of those functions/events and use that to
        >> create the second table with its own DataSource set to a JS_ARRAY
        > response
        >> type. Remember that in the doBeforeXXX functions you have to return
        > the
        >> last argument received.
        >>
        >> Satyam
        >>
        >>
        >>
        >> ----- Original Message -----
        >> From: "hifire81" <hifire@...>
        >> To: <ydn-javascript@yahoogroups.com>
        >> Sent: Friday, May 23, 2008 10:58 PM
        >> Subject: [ydn-javascript] 2 Datatables 1 Datasource
        >>
        >>
        >> > Hi All,
        >> >
        >> > I have a page outputting a json string that I would like to use to
        >> > populate two data tables (to reduce requests to the server).
        >> >
        >> > I see that you can specify where to look in the data with the response
        >> > schema and for one datatable that works. If I initialize one
        >> > datasource, set the responseSchema, pass it to a datatable, modify the
        >> > response schema and send it to another datatable, I would think that
        >> > would wreck the data for the first table.
        >> >
        >> > I guess it makes more sense to do things manually. Set up my own
        >> > timer, get the json string and update two datasources with a JSARRAY
        >> > created from subsets of the json string. I haven't been able to figure
        >> > out how to update a datasource with a JSARRAY. Do I want to do that
        >> > with sendRequest somehow?
        >> >
        >> > TIA
        >> >
        >> > -JD
        >> >
        >> >
        >> > ------------------------------------
        >> >
        >> > Yahoo! Groups Links
        >> >
        >> >
        >> >
        >>
        >>
        >>
        > --------------------------------------------------------------------------------
        >>
        >>
        >>
        >> No virus found in this incoming message.
        >> Checked by AVG.
        >> Version: 8.0.100 / Virus Database: 269.24.1/1463 - Release Date:
        > 23/05/2008
        >> 15:36
        >>
        >
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >


        --------------------------------------------------------------------------------



        No virus found in this incoming message.
        Checked by AVG.
        Version: 8.0.100 / Virus Database: 270.0.0/1484 - Release Date: 04/06/2008
        16:40
      • hifire81
        Thanks Satyam, I didn t see your response from a while back! I think I ve just about got it now. Refer to the screen shot of firebug below:
        Message 3 of 6 , Aug 28, 2008
        • 0 Attachment
          Thanks Satyam,

          I didn't see your response from a while back! I think I've just about
          got it now.

          Refer to the screen shot of firebug below:
          http://farm4.static.flickr.com/3020/2806231813_dcc19e17bf_o_d.png

          I want to pass the calls portion of oResponse to this.dt_calls and the
          hosts portion of oResponse to this.dt_hosts. I can't quite figure out
          how to use the oResponse object.

          I tried: oResponse.results[0], oResponse.results["hosts"],
          oResponse.results[0].hosts, etc... and none seem to be valid.

          I declared my datasource as:

          this.ds_calls_hosts = new YAHOO.util.DataSource (
          "/index.php/site/app/call/live/json?"
          );

          this.ds_calls_hosts.responseType = YAHOO.util.DataSource.TYPE_JSON;
          this.ds_calls_hosts.responseSchema = {fields: ["calls","hosts"]};

          this.ds_calls_hosts.setInterval (
          10000,
          null,
          {
          success: Site.App.StatusTables.update,
          failure: Site.App.StatusTables.update
          }
          );

          Here's an example of the json data:

          {"calls":[{"host":"","channel":"","dnis":"","ani":"","length":"","csn":"No
          Calls.","script":"","form":"","result_name":"","result":""}],"hosts":[{"name":"server1.plum.imi.ca","channels":"0
          \/ 48","version":"2.6.0.25","uptime":"1d 2h
          39:26","total_calls":"100"},{"name":"server2.plum.imi.ca","channels":"0 \/
          48","version":"2.6.0.25","uptime":"43d 10h 53:00","total_calls":"0"}]}


          --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@...> wrote:
          >
          > Jd,
          >
          > sorry for the delay, been out of town. Polling, ok, that's a different
          > story then.
          >
          > What I would do is to create the two datatables with any sort of
          DataSources
          > with empty local data. Type JS_ARRAY would be the easiest. You can
          use the
          > initialLoad configuration attribute so that it doesn't even try to load
          > anything from those. You can proibably manage with just one
          DataSource for
          > both since, preventing the initialLoad of data, they won't be called
          anyway.
          >
          > Then create an extra DataSources which will be remote, pointing to the
          > actual source of data. You can use DataSource method setInterval
          for the
          > polling:
          > http://developer.yahoo.com/yui/datasource/#polling
          >
          > You should provide a function of your own as the callback in the
          call to
          > setInterval. In that function, you would call the methods to fill
          up each
          > of the DataTables with the data just received:
          >
          > http://developer.yahoo.com/yui/datasource/#hooking
          >
          > Satyam
          >
          >
          >
          > ----- Original Message -----
          > From: "hifire81" <hifire@...>
          > To: <ydn-javascript@yahoogroups.com>
          > Sent: Monday, June 02, 2008 5:04 PM
          > Subject: [ydn-javascript] Re: 2 Datatables 1 Datasource
          >
          >
          > > Satyam,
          > >
          > > That's a good idea for the first request, but what if I want to enable
          > > polling? If I create a new datatable object every poll, the whole
          > > table gets redrawn and that looks bad.
          > >
          > > If I enable polling and set the initial request to a JS_ARRAY, will it
          > > look in the same array instance on subsequent polls?
          > >
          > > -JD
          > >
          > > --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@> wrote:
          > >>
          > >> You could setup one DataTable with its DataSource pointing to the
          > > remote
          > >> source of that. You could override any of the doBeforeXXX
          functions in
          > >> DataSource or listen to one of the response events (I don't recall
          > > which one
          > >> provides you the data already parsed). You can get the parsed data
          > > received
          > >> for the initial table in any of those functions/events and use
          that to
          > >> create the second table with its own DataSource set to a JS_ARRAY
          > > response
          > >> type. Remember that in the doBeforeXXX functions you have to return
          > > the
          > >> last argument received.
          > >>
          > >> Satyam
          > >>
          > >>
          > >>
          > >> ----- Original Message -----
          > >> From: "hifire81" <hifire@>
          > >> To: <ydn-javascript@yahoogroups.com>
          > >> Sent: Friday, May 23, 2008 10:58 PM
          > >> Subject: [ydn-javascript] 2 Datatables 1 Datasource
          > >>
          > >>
          > >> > Hi All,
          > >> >
          > >> > I have a page outputting a json string that I would like to use to
          > >> > populate two data tables (to reduce requests to the server).
          > >> >
          > >> > I see that you can specify where to look in the data with the
          response
          > >> > schema and for one datatable that works. If I initialize one
          > >> > datasource, set the responseSchema, pass it to a datatable,
          modify the
          > >> > response schema and send it to another datatable, I would think
          that
          > >> > would wreck the data for the first table.
          > >> >
          > >> > I guess it makes more sense to do things manually. Set up my own
          > >> > timer, get the json string and update two datasources with a
          JSARRAY
          > >> > created from subsets of the json string. I haven't been able to
          figure
          > >> > out how to update a datasource with a JSARRAY. Do I want to do that
          > >> > with sendRequest somehow?
          > >> >
          > >> > TIA
          > >> >
          > >> > -JD
          > >> >
          > >> >
          > >> > ------------------------------------
          > >> >
          > >> > Yahoo! Groups Links
          > >> >
          > >> >
          > >> >
          > >>
          > >>
          > >>
          > >
          --------------------------------------------------------------------------------
          > >>
          > >>
          > >>
          > >> No virus found in this incoming message.
          > >> Checked by AVG.
          > >> Version: 8.0.100 / Virus Database: 269.24.1/1463 - Release Date:
          > > 23/05/2008
          > >> 15:36
          > >>
          > >
          > >
          > >
          > > ------------------------------------
          > >
          > > Yahoo! Groups Links
          > >
          > >
          > >
          >
          >
          >
          --------------------------------------------------------------------------------
          >
          >
          >
          > No virus found in this incoming message.
          > Checked by AVG.
          > Version: 8.0.100 / Virus Database: 270.0.0/1484 - Release Date:
          04/06/2008
          > 16:40
          >
        • hifire81
          I gave it another 5 minutes of thinking and got it working! Yay. Here s the contents of my datasource s success callback function: ... update: function
          Message 4 of 6 , Aug 29, 2008
          • 0 Attachment
            I gave it another 5 minutes of thinking and got it working! Yay.

            Here's the contents of my datasource's success callback function:
            ...
            update: function (oRequest, oResponse, oPayload) {

            var dataset1_results = {};
            dataset1_results.results = oResponse.results[0].dataset1;

            var dataset2_results = {};
            dataset2_results.results = oResponse.results[0].dataset2;

            datatable1.onDataReturnInitializeTable(oRequest,dataset1_results,oPayload);

            datatable2.onDataReturnInitializeTable(oRequest,dataset2_results,oPayload);
            },
            ...

            Thanks Satyam. Your help is greatly appreciated.

            --- In ydn-javascript@yahoogroups.com, "hifire81" <hifire@...> wrote:
            >
            > Thanks Satyam,
            >
            > I didn't see your response from a while back! I think I've just about
            > got it now.
            >
            > Refer to the screen shot of firebug below:
            > http://farm4.static.flickr.com/3020/2806231813_dcc19e17bf_o_d.png
            >
            > I want to pass the calls portion of oResponse to this.dt_calls and the
            > hosts portion of oResponse to this.dt_hosts. I can't quite figure out
            > how to use the oResponse object.
            >
            > I tried: oResponse.results[0], oResponse.results["hosts"],
            > oResponse.results[0].hosts, etc... and none seem to be valid.
            >
            > I declared my datasource as:
            >
            > this.ds_calls_hosts = new YAHOO.util.DataSource (
            > "/index.php/site/app/call/live/json?"
            > );
            >
            > this.ds_calls_hosts.responseType = YAHOO.util.DataSource.TYPE_JSON;
            > this.ds_calls_hosts.responseSchema = {fields: ["calls","hosts"]};
            >
            > this.ds_calls_hosts.setInterval (
            > 10000,
            > null,
            > {
            > success: Site.App.StatusTables.update,
            > failure: Site.App.StatusTables.update
            > }
            > );
            >
            > Here's an example of the json data:
            >
            >
            {"calls":[{"host":"","channel":"","dnis":"","ani":"","length":"","csn":"No
            >
            Calls.","script":"","form":"","result_name":"","result":""}],"hosts":[{"name":"server1.plum.imi.ca","channels":"0
            > \/ 48","version":"2.6.0.25","uptime":"1d 2h
            >
            39:26","total_calls":"100"},{"name":"server2.plum.imi.ca","channels":"0 \/
            > 48","version":"2.6.0.25","uptime":"43d 10h 53:00","total_calls":"0"}]}
            >
            >
            > --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@> wrote:
            > >
            > > Jd,
            > >
            > > sorry for the delay, been out of town. Polling, ok, that's a
            different
            > > story then.
            > >
            > > What I would do is to create the two datatables with any sort of
            > DataSources
            > > with empty local data. Type JS_ARRAY would be the easiest. You can
            > use the
            > > initialLoad configuration attribute so that it doesn't even try to
            load
            > > anything from those. You can proibably manage with just one
            > DataSource for
            > > both since, preventing the initialLoad of data, they won't be called
            > anyway.
            > >
            > > Then create an extra DataSources which will be remote, pointing to
            the
            > > actual source of data. You can use DataSource method setInterval
            > for the
            > > polling:
            > > http://developer.yahoo.com/yui/datasource/#polling
            > >
            > > You should provide a function of your own as the callback in the
            > call to
            > > setInterval. In that function, you would call the methods to fill
            > up each
            > > of the DataTables with the data just received:
            > >
            > > http://developer.yahoo.com/yui/datasource/#hooking
            > >
            > > Satyam
            > >
            > >
            > >
            > > ----- Original Message -----
            > > From: "hifire81" <hifire@>
            > > To: <ydn-javascript@yahoogroups.com>
            > > Sent: Monday, June 02, 2008 5:04 PM
            > > Subject: [ydn-javascript] Re: 2 Datatables 1 Datasource
            > >
            > >
            > > > Satyam,
            > > >
            > > > That's a good idea for the first request, but what if I want to
            enable
            > > > polling? If I create a new datatable object every poll, the whole
            > > > table gets redrawn and that looks bad.
            > > >
            > > > If I enable polling and set the initial request to a JS_ARRAY,
            will it
            > > > look in the same array instance on subsequent polls?
            > > >
            > > > -JD
            > > >
            > > > --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@> wrote:
            > > >>
            > > >> You could setup one DataTable with its DataSource pointing to the
            > > > remote
            > > >> source of that. You could override any of the doBeforeXXX
            > functions in
            > > >> DataSource or listen to one of the response events (I don't recall
            > > > which one
            > > >> provides you the data already parsed). You can get the parsed data
            > > > received
            > > >> for the initial table in any of those functions/events and use
            > that to
            > > >> create the second table with its own DataSource set to a JS_ARRAY
            > > > response
            > > >> type. Remember that in the doBeforeXXX functions you have to
            return
            > > > the
            > > >> last argument received.
            > > >>
            > > >> Satyam
            > > >>
            > > >>
            > > >>
            > > >> ----- Original Message -----
            > > >> From: "hifire81" <hifire@>
            > > >> To: <ydn-javascript@yahoogroups.com>
            > > >> Sent: Friday, May 23, 2008 10:58 PM
            > > >> Subject: [ydn-javascript] 2 Datatables 1 Datasource
            > > >>
            > > >>
            > > >> > Hi All,
            > > >> >
            > > >> > I have a page outputting a json string that I would like to
            use to
            > > >> > populate two data tables (to reduce requests to the server).
            > > >> >
            > > >> > I see that you can specify where to look in the data with the
            > response
            > > >> > schema and for one datatable that works. If I initialize one
            > > >> > datasource, set the responseSchema, pass it to a datatable,
            > modify the
            > > >> > response schema and send it to another datatable, I would think
            > that
            > > >> > would wreck the data for the first table.
            > > >> >
            > > >> > I guess it makes more sense to do things manually. Set up my own
            > > >> > timer, get the json string and update two datasources with a
            > JSARRAY
            > > >> > created from subsets of the json string. I haven't been able to
            > figure
            > > >> > out how to update a datasource with a JSARRAY. Do I want to
            do that
            > > >> > with sendRequest somehow?
            > > >> >
            > > >> > TIA
            > > >> >
            > > >> > -JD
            > > >> >
            > > >> >
            > > >> > ------------------------------------
            > > >> >
            > > >> > Yahoo! Groups Links
            > > >> >
            > > >> >
            > > >> >
            > > >>
            > > >>
            > > >>
            > > >
            >
            --------------------------------------------------------------------------------
            > > >>
            > > >>
            > > >>
            > > >> No virus found in this incoming message.
            > > >> Checked by AVG.
            > > >> Version: 8.0.100 / Virus Database: 269.24.1/1463 - Release Date:
            > > > 23/05/2008
            > > >> 15:36
            > > >>
            > > >
            > > >
            > > >
            > > > ------------------------------------
            > > >
            > > > Yahoo! Groups Links
            > > >
            > > >
            > > >
            > >
            > >
            > >
            >
            --------------------------------------------------------------------------------
            > >
            > >
            > >
            > > No virus found in this incoming message.
            > > Checked by AVG.
            > > Version: 8.0.100 / Virus Database: 270.0.0/1484 - Release Date:
            > 04/06/2008
            > > 16:40
            > >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.