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

Re: Please, need help for JSON DataSource population!

Expand Messages
  • alaryutin
    Thanks, Satyam! I already resolved that problem - i just had to address to formattedDate through array like date[ formattedDate ]. Thanks a lot for your
    Message 1 of 7 , Aug 18, 2008
    • 0 Attachment
      Thanks, Satyam!

      I already resolved that problem - i just had to address to
      'formattedDate' through array like date['formattedDate'].

      Thanks a lot for your patience!

      Hope you can answer some my further quesions on YUI!

      Regards,

      Alex.


      --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
      >
      > Sorry, not a clue. Do you have Firebug installed? I would ask you if
      > your application is on a public place so I can run it and put a
      > breakpoint with Firebug (which you can still do and I'll give it a
      try),
      > but I am sure that if you do just the same, knowing your own
      application
      > as you do, you would probably find out faster. Firefox and Firebug are
      > both free and they are a great help.
      >
      > Satyam
      >
      >
      > alaryutin wrote:
      > > Thanks for prompt response!!!
      > >
      > > Yes, with the same object... Like the following:
      > >
      > > this.myParser = function(o) {
      > > YAHOO.log(YAHOO.lang.JSON.stringify(o.date)); // outputs
      > > '{"formattedDate":"08/14/2008"}'
      > > YAHOO.log(o.date.formattedDate); // error: o.date is unidentified
      > > }
      > >
      > > Any ideas what might be the problem?
      > >
      > > Alex
      > >
      > > --- In ydn-javascript@yahoogroups.com, Satyam <satyam@> wrote:
      > >
      > >> Is it dealing with the same column or does the column have mixed
      data?
      > >> In your sample, some of the columns had a date member, others a
      number
      > >> member, might it be complaining about another column or another
      record
      > >> with a different structure?
      > >>
      > >> alaryutin wrote:
      > >>
      > >>> Thanks a lot, Satyam!!! That really worked. But one more stupid
      > >>> question please....
      > >>>
      > >>> Now my parser for testing purposes looks like
      > >>>
      > >>> this.myParser = function(o) {
      > >>> return YAHOO.lang.JSON.stringify(o.date);
      > >>> }
      > >>>
      > >>> and it returns proper value '{"formattedDate":"08/14/2008"}' as
      > >>>
      > > expected.
      > >
      > >>> But when i am trying to change it to
      > >>> this.myParser = function(o) {
      > >>> return o.date.formattedDate;
      > >>> }
      > >>>
      > >>> it displays error 'o.date is unidentified'.... What might be a
      > >>>
      > > problem?
      > >
      > >>> Many thanks in advance.
      > >>>
      > >>> Alex
      > >>>
      > >>>
      > >>> --- In ydn-javascript@yahoogroups.com, Satyam <satyam@> wrote:
      > >>>
      > >>>
      > >>>> I think that the DataSource is doing its job Ok, the problem is
      > >>>>
      > > that it
      > >
      > >>>> is filling the Recordset that the DataTable uses to display the
      data
      > >>>> with object literals, like
      > >>>> {visible:true,date:{formattedDate:"08/14/2008"}} which the
      DataTable
      > >>>> doesn't know how to display.
      > >>>>
      > >>>> The best thing is to declare the responseSchema.fields array
      with a
      > >>>> parser for each column, like
      > >>>>
      > >>>> this.myDataSource.responseSchema = {
      > >>>> resultsList: "report.row",
      > >>>> fields: [{key:"column[0]",
      > >>>> parser:myParser},{key:"column[1]",
      > >>>>
      > > parser:myParser},{key:"column[2]",
      > >
      > >>>> parser:myParser}]
      > >>>> };
      > >>>>
      > >>>> The myParser function will receive an object such as
      > >>>> {visible:true,date:{formattedDate:"08/14/2008"}} and it would
      > >>>>
      > > have to
      > >
      > >>>> return a valid JavaScript native Date object, it would receive an
      > >>>>
      > >>>>
      > >>> object
      > >>>
      > >>>
      > >>>> containing a number represented as a string and it would have to
      > >>>>
      > > return
      > >
      > >>>> the parseInt() of it and so on. Whatever this parser function
      > >>>>
      > > returns
      > >
      > >>>> is what will be stored in the Recordset and the DataTable can
      handle
      > >>>>
      > >>>>
      > >>> those.
      > >>>
      > >>>
      > >>>> Satyam
      > >>>>
      > >>>>
      > >>>>
      > >>>> alaryutin wrote:
      > >>>>
      > >>>>
      > >>>>> Gentlemen, could you please help me with following?...
      > >>>>>
      > >>>>> I have a JSON notation, like following:
      > >>>>>
      > >>>>> {
      > >>>>> "report": {
      > >>>>> "row": [
      > >>>>> {
      > >>>>> "column": [
      > >>>>> {
      > >>>>> "visible": "true",
      > >>>>> "date": {
      > >>>>> "formattedDate": "08/14/2008"
      > >>>>> }
      > >>>>> },
      > >>>>> {
      > >>>>> "visible": "true",
      > >>>>> "number": "0"
      > >>>>> }
      > >>>>> ]
      > >>>>> }
      > >>>>> ; ] }
      > >>>>> }
      > >>>>>
      > >>>>> E.g. 'report' contains array of 'row's and each 'row' contains
      > >>>>>
      > > array
      > >
      > >>>>> of 'column's.
      > >>>>>
      > >>>>> Does anyone know, how to present this data to datasource to use
      > >>>>>
      > > later
      > >
      > >>>>> in datatable? So idea is:
      > >>>>>
      > >>>>> ....
      > >>>>> this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
      > >>>>> this.myDataSource.connXhrMode = "queueRequests";
      > >>>>> this.myDataSource.responseSchema = {
      > >>>>> resultsList: "report.row",
      > >>>>> fields: ["column.0","column.1","column.2"]
      > >>>>> };
      > >>>>>
      > >>>>> E.g. every column in resulting datasource should present
      subsequent
      > >>>>> elements of 'column' array. But i am not sure how to define the
      > >>>>>
      > > key:
      > >
      > >>>>> neither 'column[0]' nor 'column.0' or similar are working. As
      > >>>>>
      > > result
      > >
      > >>>>> of above, dataset & datatable are populated with proper number of
      > >>>>> 'row's, but all columns are empty.
      > >>>>>
      > >>>>> Many thanks in advance for response.
      > >>>>>
      > >>>>> Alex.
      > >>>>>
      > >>>>> No virus found in this incoming message.
      > >>>>> Checked by AVG - http://www.avg.com
      > >>>>> Version: 8.0.138 / Virus Database: 270.6.2/1609 - Release Date:
      > >>>>>
      > >>>>>
      > >>> 13/08/2008 6:43
      > >>>
      > >>>
      > >>>
      > >>>
      > >>> ------------------------------------
      > >>>
      > >>> 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.2/1609 - Release Date:
      > >>>
      > > 13/08/2008 6:43
      > >
      > >>>
      > >>>
      > >>>
      > >
      > >
      > >
      > > ------------------------------------
      > >
      > > 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.3/1611 - Release Date:
      14/08/2008 6:20
      > >
      > >
      > >
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.