looping over the rows in a model

in order to compose a complex report I’m addressing 2 models… one gives me a count of client encounters for each client the next is the actual list of encounters for a given time period. I’m using a for loop to loop over the list of encounters. I suspect there is an $.each idiom i could use… but i could not find an example in the api sample code is there a method, or a way to loop over the data in a model directly ? var params = arguments[0] $ = skuid.$; // get the data from the first tab counts = skuid.model.getModel(‘HH_Client_Counts’).data; // build an array holding the ids of the clients that have had more than 1 service returns = [‘0000’]; for(var current_client=0; current_client<counts.length; current_client++) { if (counts[current_client][‘sumIsServicec’] > 1){ returns.push(counts[current_client][‘clientrClientIDCopyc’]); } } // get the model for this tab, because we will need to use its methods encounters = skuid.model.getModel(‘HH_Client_Encounters’); // get the data portion of the model encounter_data = encounters.data; var row = ‘’; var last_date = ‘’; var update_value = 0; var old_client_id = ‘’; var client_id=0; var set_selected = false; // loop over the data for(var current_row=0; current_row<encounter_data.length; current_row++) { //console.log(‘id—’ + encounter_data[current_row][‘Id’]); row = encounters.getRowById(encounter_data[current_row][‘Id’]); client_id = encounter_data[y][‘Client__r’][‘Name’]; // we want to flag the encounter record the first time a new client id appears // therefore if a client has more than one encounter, only the last one will be flagged // the model is sorted by client last, first and service date Descending if (client_id === old_client_id){ set_selected = false; } else{ set_selected = true; // now we check to see if the client has more than one encounter in the year // we only do this for the encounters that will be “selected” if ( returns.indexOf(client_id) > 1){ update_value = 1; } else { update_value = 0; } encounters.updateRow(row,{‘HH_Count__c’:update_value,‘HH_selected__c’:set_selected}); } // console.log(‘==selected ==’ + set_selected + ‘=new====’ + client_id + ‘==old==’ + old_client_id); // reset the variable for the next pass old_client_id = client_id; } // for current_row encounters.save();

I actually got this syntax from the skuid.model documentation, found here 
http://help.skuidify.com/s/tutorials/m/11720/l/129014-skuid-model 
in the code at the end of the page. The basic syntax is like so:

  1. $.each(myModel.data,function(i,row){
  2. myModel.updateRow(row,myfield, myValue);
  3. });

Yep, Moshe’s right on. jQuery’s generic $.each is what you’ll want to use.