By Alvin Alexander. Last updated: June 6, 2016
I learned today that you break out of a Sencha ExtJS Store each
loop by returning false
from your function. This code shows the technique:
// check to see if the task description is already in the store for this project taskAlreadyExistsInProject: function(projectId, taskName) { var tasksStore = this.getTasksStore(); var matchIsFound = false; tasksStore.each(function(record) { if ((record.data.description == taskName) && (record.data.projectId == projectId)) { matchIsFound = true; // don't use 'me' or 'this' here return false; // this breaks out of the 'each' loop } }); return matchIsFound; },
I don’t think you’re supposed to access the data
object as I’ve done here, but the return false
part, I know that’s correct.
If you needed to see how to break out of a Store each
loop early, I hope this example has been helpful.