vendredi 13 juin 2014

How to find if a particular value exits in a data store using each method

Hi All,

I have a editable combo box where I am getting the values from a data store. Now if a user types something in that combo box and clicks submit, I need to verify if that value exists in the store. I need to throw an alert in case if the value is not there. For this validation, I am getting the store and the value that the user typed in and trying to do the following.


myStore.each(function(item){

if(item.data.referenceId == selectedReference ) {

return;

}


});

so if the value is present in the store, it returns from the function and will continue with the rest of the validations, but if the value is not present I am getting a problem where it throws alert statement n number of times where n is the number of records in the store. I am not sure if I should be using the each method for my requirement. Can you please let me know if there is any other way of doing this or if I am missing something here.


Thanks,





Aucun commentaire:

Enregistrer un commentaire