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

"data error" in YUI datatable.

Expand Messages
  • defmer
    I need a little help and insight as what could be going wrong here. I have php on server side which prints/returns json ed array. when I print it, it prints
    Message 1 of 2 , Jan 2, 2009
    • 0 Attachment
      I need a little help and insight as what could be going wrong here. I
      have php on server side which prints/returns json'ed array. when I
      print it, it prints out the following

      [{"count":"1","address":"usa","phone":"1234567897","zip":"12345"},
      {"count":"2","address":"usa","phone":"1234567897","zip":"12345"},
      {"count":"3","address":"usa","phone":"1234567897","zip":"12345"}]

      and my script so far is this :

      function MakeRequest(){

      var myColumnDefs = [
      {key:"count", label:"count"},
      {key:"address", label:"address"},
      {key:"phone", label:"phone"},
      {key:"zip", label:"zip"}];

      var myDataSource = new YAHOO.util.XHRDataSource("hello.php");

      myDataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON;

      myDataSource.responseSchema = {
      fields: ["count","address","phone","zip"]
      };

      var myDataTable = new YAHOO.widget.DataTable("myContainer",
      myColumnDefs, myDataSource);

      }
      </script>
      </head>
      <body class="yui-skin-sam">
      <input type='button'
      onclick='MakeRequest();'
      value='Display'/>
      <div id="myContainer">
      </div>
      </body>
      </html>

      I can see the table with columns being displayed, for a sec is says
      "data loading" and then displays "data error" and getfirebug does not
      even show an error. so not really sure what could be going wrong here?
      Thank you
    • Satyam
      That is a known bug that reappeared in 2.6 after it had been fixed in 2.5 or 2.4. You can fix it on the server side by making your data look like:
      Message 2 of 2 , Jan 2, 2009
      • 0 Attachment
        That is a known bug that reappeared in 2.6 after it had been fixed in
        2.5 or 2.4. You can fix it on the server side by making your data look
        like:

        {response:[{"count":"1","address":"usa","phone":"1234567897","zip":"12345"},
        {"count":"2","address":"usa","phone":"1234567897","zip":"12345"},
        {"count":"3","address":"usa","phone":"1234567897","zip":"12345"}]}

        and adding a responseSchema.resultsList = "response"

        or you could fix it by overriding doBeforeParseData, which I can tell
        you how to do it if you really can't fix it by doing the above, which I
        recommend.

        Satyam


        defmer wrote:
        > I need a little help and insight as what could be going wrong here. I
        > have php on server side which prints/returns json'ed array. when I
        > print it, it prints out the following
        >
        > [{"count":"1","address":"usa","phone":"1234567897","zip":"12345"},
        > {"count":"2","address":"usa","phone":"1234567897","zip":"12345"},
        > {"count":"3","address":"usa","phone":"1234567897","zip":"12345"}]
        >
        > and my script so far is this :
        >
        > function MakeRequest(){
        >
        > var myColumnDefs = [
        > {key:"count", label:"count"},
        > {key:"address", label:"address"},
        > {key:"phone", label:"phone"},
        > {key:"zip", label:"zip"}];
        >
        > var myDataSource = new YAHOO.util.XHRDataSource("hello.php");
        >
        > myDataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON;
        >
        > myDataSource.responseSchema = {
        > fields: ["count","address","phone","zip"]
        > };
        >
        > var myDataTable = new YAHOO.widget.DataTable("myContainer",
        > myColumnDefs, myDataSource);
        >
        > }
        > </script>
        > </head>
        > <body class="yui-skin-sam">
        > <input type='button'
        > onclick='MakeRequest();'
        > value='Display'/>
        > <div id="myContainer">
        > </div>
        > </body>
        > </html>
        >
        > I can see the table with columns being displayed, for a sec is says
        > "data loading" and then displays "data error" and getfirebug does not
        > even show an error. so not really sure what could be going wrong here?
        > Thank you
        >
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >
        > ------------------------------------------------------------------------
        >
        >
        > No virus found in this incoming message.
        > Checked by AVG - http://www.avg.com
        > Version: 8.0.176 / Virus Database: 270.10.2/1872 - Release Date: 02/01/2009 13:10
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.