getItemsByPropValue(items: Object, propName: String, value: Object, asPPObj: Boolean, first: Boolean);
items. Array, by which the search is performed.
propName. A string containing enumeration of sequence of nested properties separated by comma.
value. Property value.
asPPObj. Indicates whether the source array is the PP.Object object. Available Values:
first. Indicates whether only the first element is checked in the source array. Available Values:
true. Only the first element is checked in the source array.
false. The entire source array is used in search.
The getItemsByPropValue method returns an array of all source array elements, which contain the property with the specified name and value.
To execute the example, the HTML page must contain links to the jquery.js, PP.js scenario files, and the PP.css styles file. Create an array of elements containing text description and different number of properties, set different values to the properties and get an array of elements containing the specified property:
// Create an array containing elements with description and different number of properties var item1 = { field1: "right", description: "first object" }; var item2 = { field1: "wrong", field2: "right", description: "second object" }; var item3 = { field1: "right", field2: "right", field3: "right", description: "third object" }; var items = { f1: item1, f2: item2, f3: item3 }; // Get an array of elements, which contain the "field1" property with the "right" value var result = PP.getItemsByPropValue(items, "field1", "right", True, False); // Output description of all objects in the obtained array to the browser console for (var i in result) { console.log(result[i].description); }
After executing the example the browser console displays text description of object that contain the "field1" property with the "right" value:
first object
third object