Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Feb 2011
    Posts
    104
    Vote Rating
    0
    headkit is on a distinguished road

      0  

    Default Unanswered: how to display csv data

    Unanswered: how to display csv data


    hi there!

    what is the best way to read and display some data from a csv data source. lets say I want to display an apple financial report with touch charts...

    thnx!

  2. #2
    Sencha User
    Join Date
    Nov 2010
    Posts
    168
    Vote Rating
    0
    philogb is on a distinguished road

      0  

    Default


    Hi - Unfortunately there is no buil-in CSV reader in Sencha Touch. I would try to convert the CSV string into JSON and then feed that into a Store. Given a CSV string with `\n` and `,` separators the code for converting it into JSON would eb something like this:

    Code:
    var json = [],
          lines = csv.split('\n');
    
    for (var i = 0, l = lines.length; i < l; ++i) {
      var fields = lines[i].split(','),
            jsonElement = {};
    
      jsonElement['field1'] = fields[0];
      jsonElement['field2'] = fields[1];
      //... etc for each field
    
      json.push(jsonElement);
    
    }
    This code should return the json needed to create a store with it.

    I hope his helps,

Thread Participants: 1