2

Is there any jquery function to get specifc data by any property from list?

Here is my array in page.

[{"ConId":0,"ConCurIdSource":1,"ConCurIdTarget":10,"ConConversionRate":0.27,"IsActive":null,"CreatedBy":null,"CreatedDate":null,"UpdatedBy":null,"UpdatedDate":null,"Abbrivation":"AEDTOPKR"},

{"ConId":0,"ConCurIdSource":10,"ConCurIdTarget":1,"ConConversionRate":27,"IsActive":null,"CreatedBy":null,"CreatedDate":null,"UpdatedBy":null,"UpdatedDate":null,"Abbrivation":"PKRTOAED"},

{"ConId":0,"ConCurIdSource":10,"ConCurIdTarget":14,"ConConversionRate":101,"IsActive":null,"CreatedBy":null,"CreatedDate":null,"UpdatedBy":null,"UpdatedDate":null,"Abbrivation":"PKRTOUSD"}]

i need to get all maching object by Abbrivation

enter image description here

2 Answers 2

4

No need for jQuery, just use the standard filter function :

var matches = myArray.filter(function(v){ return v.Abbrivation==="PKRTOAED" });
Sign up to request clarification or add additional context in comments.

Comments

1

a more neat solution is to use jQuery .grep() as following

new_array = jQuery.grep(my_array, function( a ) {
  return a.prop == "YOUR_DESIRED_VALUE";
});

Source:

http://api.jquery.com/jQuery.grep/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.