using afnFiltering, aData is always the same value as the last array passed to it.

using afnFiltering, aData is always the same value as the last array passed to it.

jentreejentree Posts: 4Questions: 1Answers: 0
edited February 2014 in General
Here is how I am setting up the column:
[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]

This is working fantastic. In the column (table cell), I am getting a list of part numbers. Example: "123, 1234, 12345..."

I have a drop-down with the same part numbers. When a user chooses a value from the drop down, I would like to filter the rows to show only the rows that contain that value.

Here is how I am attempting:
[code]
$.fn.dataTableExt.afnFiltering.push(
function(oSettings, aData, iDataIndex) {
if ($('#showHideByPartNumber').val() === "" || $('#showHideByPartNumber').val() === 'undefined')
{
return true;
}
else
{
console.log(typeof (aData[9])); // Returns Object
console.log(aData[9]); // Returns ["456", "789", "0123"...]
}
}
);
[/code]
Let's say I have 3 rows of data coming back. The "mRender" in the column setup is rendering the part numbers correctly for each row. The trouble I'm running into, is that when filtering, "aData[9]" is the same value for each row.

For example, I will get:
["987", "6543", "210"...]
["987", "6543", "210"...]
["987", "6543", "210"...]
for each result (aData).

When in fact the results should look like this:
["123", "1234", "12345"...]
["123456", "1234567", "12345678"...]
["987", "6543", "210"...]

I'm always getting the last array values as the only value. I'm stumbling on how I can parse through the data.

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