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

Help with DataTable - Loads the data but does not display it in the table.

Expand Messages
  • tisenti
    Can anybody help? Firebug tells me that it successfully loads my XML via XHR. Datatable then writes the correct number of rows but does not insert the
    Message 1 of 3 , May 1, 2008
      Can anybody help? Firebug tells me that it successfully loads my XML via XHR. Datatable then writes the correct number of <table> rows but does not insert the data.

      Here is my code:

      <div id="localxml"></div>

      <script type="text/javascript">


      YAHOO.util.Event.addListener(window, "load", function() {
          YAHOO.example.Local_XML = new function() {
              this.connectionCallback = {
                  success: function(o) {
                 
                      var xmlDoc = o.responseXML;

                      var myColumnDefs = [
                          {key:"Counter"},
                          {key:"Yachts"},
                          {key:"Name"},
                          {key:"Email", sortable:true},
                          {key:"CompanyEmail"}
                      ];

                      this.myDataSource = new YAHOO.util.DataSource(xmlDoc);
                      this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_XML;
                      this.myDataSource.responseSchema = {
                          resultNode: "row",
                          fields: ["Counter","Yachts", "Name","Email","CompanyEmail"]
                      };

                      this.myDataTable = new YAHOO.widget.DataTable("localxml", myColumnDefs, this.myDataSource);

                  },
                  failure: function(o) {

                  }
              };

              this.getXML = YAHOO.util.Connect.asyncRequest("GET", "sql-to-xml.asp", this.connectionCallback);
             
          };
      });

      </script>


      And the XML
      <?xml version="1.0" encoding="ISO-8859-1" ?>
      - <results xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      - <row>
        <counter>...</counter>
        <yachts>...</yachts>
        <name>...</name>
        <email>...</email>
      <company_email>...</company_email>
      </row>
      </results>


      Please help!
    • Satyam
      The names in the fields array should be exactly like the ones on the XML data and so should the ones in the columns definition. The parseXMLData function uses
      Message 2 of 3 , May 2, 2008
        The names in the fields array should be exactly like the ones on the XML data and so should the ones in the columns definition.  The parseXMLData function uses the name exactly as spelled to do a getElementsByTagName to reach the node, and that function is not case-insensitive.  If you want to give proper labels to the columns instead of the field names, use the label property on the col defs. Your row is being populated with empty rows because the parser does recognize the row and thus reserves space for it but with getElementsByTagName failing, it assumes that that particular field is missing in that row and fills it with a blank.
         
        Satyam
         
        ----- Original Message -----
        From: tisenti
        Sent: Friday, May 02, 2008 12:27 AM
        Subject: [ydn-javascript] Help with DataTable - Loads the data but does not display it in the table.

        Can anybody help? Firebug tells me that it successfully loads my XML via XHR. Datatable then writes the correct number of <table> rows but does not insert the data.

        Here is my code:

        <div id="localxml"></div>

        <script type="text/javascript">


        YAHOO.util.Event.addListener(window, "load", function() {
            YAHOO.example.Local_XML = new function() {
                this.connectionCallback = {
                    success: function(o) {
                   
                        var xmlDoc = o.responseXML;

                        var myColumnDefs = [
                            {key:"Counter"},
                            {key:"Yachts"},
                            {key:"Name"},
                            {key:"Email", sortable:true},
                            {key:"CompanyEmail"}
                        ];

                        this.myDataSource = new YAHOO.util.DataSource(xmlDoc);
                        this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_XML;
                        ti s.myDataSource.responseSchema = {
                            resultNode: "row",
                            fields: ["Counter","Yachts", "Name","Email","CompanyEmail"]
                        };

                        this.myDataTable = new YAHOO.widget.DataTable("localxml", myColumnDefs, this.myDataSource);

                    },
                    failure: function(o) {

                    }
                };

                this.getXML = YAHOO.util.Connect.asyncReqest("GET", "sql-to-xml.asp", this.connectionCallback);
               
            };
        });

        </script>


        And the XML
        <?xml version="1.0" encoding="ISO-8859-1" ?>
        - <results xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        - <row>
          <counter>...</counter>
          <yachts>...</yachts>
          <name>...</name>
          <email>...</email>
        <company_email>...</company_email>
        </row>
        </results>


        Please help!


        No virus found in this incoming message.
        Checked by AVG.
        Version: 7.5.524 / Virus Database: 269.23.7/1410 - Release Date: 01/05/2008 17:30
      • tisenti
        Beautiful - many many thanks!
        Message 3 of 3 , May 2, 2008
          Beautiful - many many thanks!
        Your message has been successfully submitted and would be delivered to recipients shortly.