Forum Post: How to iterate a read service dataset in javascript

  • Thread starter Thread starter riche
  • Start date Start date
Status
Not open for further replies.
R

riche

Guest
I am new to the mobile scene and would appreciate guidance from anyone willing. I have a select, that is populated with customers. I want to display the selected customers information in a grid below it. I have all of the information, so I don't want to request the data over again. So, on the value change event, I wrote the following code that does work: if (CustomersReadService !== undefined && CustomersReadService.data !== undefined && CustomersReadService.data.dsCustomers !== undefined && CustomersReadService.data.dsCustomers.ttCustomers !== undefined && CustomersReadService.data.dsCustomers.ttCustomers.length 0) { var selectedValue = Progress("selectCustomers").val(); var customerCount = CustomersReadService.data.dsCustomers.ttCustomers.length; for (var i=0; i customerCount ; i++) { if (CustomersReadService.data.dsCustomers.ttCustomers.custNumber == selectedValue) { var customer = CustomersReadService.data.dsCustomers.ttCustomers; Progress('lbAddress').text(customer.address); Progress('lbPhone').text(customer.phone); Progress('lbFax').text(customer.fax); ... i = customerCount ; } } } Is there a better way of getting the record that I want? I was going to use the jsdo.find method, but couldn't figure out how to. I couldn't figure out the foreach either, so I went with a standard array loop option. The find and foreach are undefined if I try them on any level of the service. I noticed that the service is actually an Appery.Datasource, but can't find any information about traversing them either.

Continue reading...
 
Status
Not open for further replies.
Back
Top