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

Re: [ydn-javascript] Re: Please help: Datatable & Chart via DataSource - subsequent weird requests.

Expand Messages
  • Satyam
    See: http://developer.yahoo.com/yui/datasource/#sendrequest That is the way you can use the DataSource to fetch the data for you independently of Charts or
    Message 1 of 4 , Aug 18, 2008
    • 0 Attachment
      See:

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

      That is the way you can use the DataSource to fetch the data for you
      independently of Charts or DataTable (in the end, both call this
      sendRequest method, the idea is that you call it yourself just once
      instead of letting each of them call it). If you read further down you
      will see that you can even set the DataSource to poll regularly for new
      data. Once you get the data locally, follow any of the examples in the
      YUI docs for DataTable that show how to work with local data sources.

      Satyam

      alaryutin wrote:
      > Thanks for the prompt response, Satyam!
      >
      > But could you please give me any clue, how i can repopulate existing
      > datasource with new data, and also re-populate datatable & chart,
      > related to this datasource?
      >
      > Many thanks in advance.
      >
      > Alex.
      >
      >
      > --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
      >
      >> Well, if what you see in the DataSource query is JSON it is because
      >>
      > that
      >
      >> is what the request to feed2.php brought so, you either make the server
      >> respond with an argument that can be used straight away in the URL
      >>
      > query
      >
      >> part, or you use the YUI JSON utility to parse the JSON message and use
      >> whatever part you care from the incoming message into the data request.
      >> It would also be better if you handle the remote fetch separately from
      >> drawing the Chart and the DataTable so you have a single request for
      >> data which you store in a local variable and then draw the Chart and
      >>
      > the
      >
      >> DataTable from the data in that variable as a local source.
      >>
      >> Satyam
      >>
      >>
      >> alaryutin wrote:
      >>
      >>> Greetings, gentlemen, could you please help me with the following
      >>> problem.
      >>>
      >>> I have a DataSource, which i initialize through ConnectionManager. I
      >>> also have a form, linked to the Manager, where i get the params from.
      >>> Here is the structure:
      >>>
      >>> <script type="text/javascript">
      >>>
      >>> YAHOO.widget.Chart.SWFURL =
      >>> "../../build//charts/assets/charts.swf";//Initializing charts
      >>> var myDataSource = new Object(); //DataSource global object
      >>> ....//other stuff
      >>> YAHOO.util.Connect.setForm("dataForm"); //setting the form to
      >>> ConnManager
      >>> YAHOO.util.Event.addListener(window, "load", function() {
      >>>
      >>> YAHOO.example.XHR_JSON = new function() {
      >>>
      >>> this.connectionCallback = {
      >>> success: function(o) {
      >>>
      >>> var myColumnDefs = [....//Column defs, parsers, etc
      >>> .....
      >>> //Datasource init section
      >>> myDataSource = new
      >>> YAHOO.util.DataSource(o.responseText);
      >>> myDataSource.connMgr = YAHOO.util.Connect;
      >>> myDataSource.connMethodPost = true;
      >>> myDataSource.responseType =
      >>> YAHOO.util.DataSource.TYPE_JSON;
      >>> myDataSource.responseSchema = {... //Response schema,
      >>> series for Chart, etc
      >>> .....
      >>> //Chart creation
      >>> var mychart = new YAHOO.widget.ColumnChart("chart",
      >>> myDataSource,
      >>> {
      >>> series:seriesDef,
      >>> xField: "column[0]"
      >>>
      >>> });
      >>> //Table Creation
      >>> this.myDataTable = new YAHOO.widget.DataTable("json",
      >>> myColumnDefs, myDataSource);
      >>>
      >>>
      >>> },
      >>> failure: function(o) {
      >>>
      >>> }
      >>> };
      >>>
      >>> // Request to feeder
      >>> this.JSONRequest = YAHOO.util.Connect.asyncRequest("POST",
      >>> "feed2.php",
      >>> this.connectionCallback);
      >>> ...
      >>> }
      >>>
      >>> The problem is that FireBug analysis shows that this script sends 3
      >>> requests. 1st - to feed2.php with proper form values. It works ok. But
      >>> when chart and table are created, the requests are send to
      >>>
      >>>
      > http://localhost:8080/yui/examples/productdb/%7B%22report%22:%7B%22row%2\
      >
      >>> 2:%5B%7B%22c.... - e.g. URL escaped JSON response, got from the
      >>>
      > feeder.
      >
      >>> As a result DataTable and Chart are not rendered.
      >>>
      >>> Does anybody know what is going on??? Any help will be much
      >>>
      > appreciated.
      >
      >>> Alex.
      >>>
      >>>
      >>>
      >>>
      >>> ------------------------------------
      >>>
      >>> Yahoo! Groups Links
      >>>
      >>>
      >>>
      >>>
      >>> No virus found in this incoming message.
      >>> Checked by AVG - http://www.avg.com
      >>> Version: 8.0.138 / Virus Database: 270.6.4/1615 - Release Date:
      >>>
      > 16/08/2008 7:11
      >
      >>>
      >>>
      >>>
      >
      >
      >
      > ------------------------------------
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      > No virus found in this incoming message.
      > Checked by AVG - http://www.avg.com
      > Version: 8.0.138 / Virus Database: 270.6.4/1615 - Release Date: 16/08/2008 7:11
      >
      >
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.