Form Question

You must Login before you can answer or comment on any questions.

Hi, I’m a newbie and doing my first project which is a Form on IOS and android.

After checking the Forging Titanium Episode 10- Forms video, I’ve finished the user interface lay out. In my app setting page, there is a URL path so the user can type in the address of the file, which contains certain info [e.g. Email address, Grade, Area …]

Can I fetch the remote CSV file to populate the fields or do I need to convert it to JSON or XML first? If I need to convert the file, I’ve seen number of csv to Jason converter on the net, which one would you recommend?

Is there some guides or someone can help me particularly on to how to populate the fields on the form after the data has been fetched? Hopefully with some code example, so let’s say if a Grade is picked the email address and the area are automatically fills out.
Any help or guide would be greatly appreciated. Thanks.

3 Answers

Accepted Answer

Hi Shahrokh

Using the HTTPClient functions of Titanium you can download any file into memory, you can then process the CSV file manually.

You would split the results using the JavaScript SPLIT command for the line breaks and loop through the records. Inside that loop SPLIT each line by the comma and you then have your data.

You can use JSON as Ashish suggests and that is a much easier way to process the data on the app side, but if you already have the data created in a format - you can work with that as well.

I would steer clear of XML unless it is already in the format as the overhead to process the results is really not worth it.

Thanks for your comments guys, I'll be asking each schools to create the data file and since they are more comfortable with the csv data entry, I have to ask for that format, as I mentioned just started to learn the language and will definitely look into the SPLIT feature you've mentioned. Thanks again

Hi Shahrokh, yes you fetch the remote CSV file to populate the fields and i think you need to convert it to JSON or XML first. you can use any CSV to JSON converter, which suits your need.

I don't have code snippet with me right now, but you can try looking for kitchen sink app for this and can google the same.

Your Answer

Think you can help? Login to answer this question!