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

Datatable - Problem parsing data accessed over XHR

Expand Messages
  • lschnoller
    The solution i found is to parse each field after the data is received from the data-source. This is kind of inefficient because each field in the response
    Message 1 of 1 , Jun 1, 2007
    • 0 Attachment
      The solution i found is to parse each field after the data is received
      from the data-source. This is kind of inefficient because each field
      in the response object needs to be checked to see if it belongs to a
      column defined in the columnSet object. This needs to be done because
      the way the dataTable class is constructed, you cannot parse data that
      hasn't been assigned a specific column.

      Try adding the following snippet at the beginning of the
      onDataReturnPopulateTable function in line 3888. See if anyone can
      help me with a better solution. Thanks!


      //************************ parse data snippet **************************
      //The following snippet updates the Response Object by parsing all the
      //field in the recordset that were assinged a column in the columnSet
      //
      var parseColumns = [];
      var aKeys = new Array();
      //alert(this._oColumnSet.keys.length);
      for (var k=0; k < this._oColumnSet.keys.length; k++) {
      aKeys.push(this._oColumnSet.keys[k].key);
      //alert(aKeys[k]);
      }

      //all records
      for (var i=0; i < oResponse.length; i++) {
      var oRawRecord = oResponse[i];

      //each field
      for (var field in oRawRecord) {
      //alert(field);
      var columnPosition = searchColumn(field, aKeys);
      //field defined in the columnSet
      if (columnPosition != -1) {
      //parse data
      //alert("Data to be parsed: " +
      oRawRecord[this._oColumnSet.keys[columnPosition].key]);
      var parsedData =
      this._oColumnSet.keys[columnPosition].parse(oRawRecord[this._oColumnSet.keys[columnPosition].key]);
      //alert("Parsed Data: " + parsedData);
      oResponse[i][field] = parsedData;
      }
      }
      }

      function searchColumn(field, aKeys) {
      var iMatch = -1;

      for (var x=0; x < aKeys.length; x++) {
      //alert("field: " + field + " || akeys: " + aKeys[x]);
      if (field == aKeys[x]) {
      iMatch = x;
      //alert("imatch: "+ iMatch);
      }
      }

      return iMatch;
      }
      //************************ end of parse data snippet
      **************************
    Your message has been successfully submitted and would be delivered to recipients shortly.