Value in table cell is object/array. Best way to filter for a given value?

Value in table cell is object/array. Best way to filter for a given value?

jentreejentree Posts: 4Questions: 1Answers: 0
edited February 2014 in General
I have a table cell that contains an object. Let's say it's a list (an array) of part numbers. I have a drop down that contains a full list of part numbers. So, if I choose a part number from the drop down, I want to filter all table rows to show my items that contain that specific part number. Each row that is shown (filtered) will show the entire array (which also contains the selected part number). Here is how I am attempting to filter:

[code]
$.fn.dataTableExt.afnFiltering.push(
function(oSettings, aData, iDataIndex) {
if ($('#partNumber').val() === "" || $('#partNumber').val() === 'undefined')
{
return true;
}
else
{
console.log('aData is: ' + typeof (aData[9])); // returns object
// Example: if my table has 20 rows, I get 20 objects back as arrays listing part numbers.

// I have tried something like this among other similar methods with no success:
if ($.inArray($('#partNumber').val(), aData[9].indexOf($('#partNumber').val())) !== -1) {
...
}
}
[/code]

Here is how I am setting up my column def:
[code]
{
'aTargets': [9],
'bSortable': true,
'bVisible': true,
'mData': 'partlist',
'mRender': function(data, type, row) {
$.each(data, function(key, val) {
if ($.inArray(val.name, partArray) === -1) {
partArray.push(val.name);
}
});

return partArray;
}
}
[/code]

Forgive any syntax errors - everything is "working" just hung up on how to search for a specific value within an object/array.

Thank you for your time!
This discussion has been closed.