I am trying to use linq.js to match a locate a object by a property. the property i need to match is in a object of arrays and then nested in array of arrays.
Json i am looping through
customSeries = [{"name":"Chantal Hamlet - Green Castle Homes","subId":"10223","bldId":"13551","data":[[179900,1386],[214900,1440],[194500,1496],[217900,1504],[189900,1542],[184900,1546],[192500,1570],[189900,1576],[191900,1598],[204900,1626],[219900,1651],[212900,1704],[214900,1787],[219900,1837],[224900,1857]],"removeByNames":[["null"],["null"],["null"],["null"],["null"],["null"],["null"],["null"],["null"],["null"],["null"],["null"],["null"],["null"],["null"]]},{"name":"Ella Sea Condos - Sahnow Construction","subId":"9761","bldId":"27380","data":[[199900,1500]],"removeByNames":[["null"]]},{"style":"smooth","color":"blue","data":[[20000,200],[40000,400],[[40000,400]],[30000,300],[[30000,300]]],"name":"Subject Property","removeByNames":[["Product1"],["Product2"],["Product3"]]}]
item to match
var modelName = 'Product2'
javascript
remove: function (e) {
removeByNames = []
var modelName = e.model.name;
// Enumerate through the series
var customSeriesSearchResults = Enumerable.From(customSeries)
.Where(function (item) {
// Enumerate through the series.removeByNames
return Enumerable.From(item.removeByNames).Any(function (modelName) {
// Find matching removeByNames.name
return Enumerable.From(removeByNames).Contains(modelName);
})
})
.ToArray();
}
customersWithProduct2 = customSeries.filter(function(customer){ return customer.modelname === 'Product2';})removeByNamesarray is mixed with arrays of string and arrays of arrays of strings... you need to flatten that down or something.