When filtering via afnFiltering, parameter iDataIndex is always 0
When filtering via afnFiltering, parameter iDataIndex is always 0
sawlus
Posts: 1Questions: 0Answers: 0
I'm trying to filter rows using plug in and also update a column for all rows. Everything works except rows are not updated because iDataIndex is always 0. Isn't it supposed to be a row number?
[code]
$.fn.dataTableExt.afnFiltering.push(
function (oSettings, aData, iDataIndex) {
//alert("in function");
var iAge = document.getElementById('age').value * 1;
var iTripLength = document.getElementById('tripLength').value * 1;
var iAgeRangeFrom = aData[0].substr(0, aData[0].indexOf("-"));
var iAgeRangeTo = aData[0].substr(aData[0].indexOf("-") + 1, aData[0].length - aData[0].indexOf("-") - 1);
var iTripLengthFrom = aData[1].substr(0, aData[1].indexOf("-"));
var iTripLengthTo = aData[1].substr(aData[1].indexOf("-") + 1, aData[1].length - aData[1].indexOf("-") - 1);
if (iTripLength != "") {
oTable = oSettings.oInstance;
oTable.fnUpdate(aData[4] * iTripLength, iDataIndex, 6);
}
if (iAge == "" && iTripLength == "") {
return true;
}
else if (iAge == "" && (iTripLengthFrom <= iTripLength && iTripLengthTo >= iTripLength)) {
return true;
}
else if ((iAge <= iAgeRangeTo && iAge >= iAgeRangeFrom) && "" == iTripLength) {
return true;
}
else if ((iAge <= iAgeRangeTo && iAge >= iAgeRangeFrom) && (iTripLengthFrom <= iTripLength && iTripLengthTo >= iTripLength)) {
return true;
}
return false;
}
);
[/code]
[code]
$.fn.dataTableExt.afnFiltering.push(
function (oSettings, aData, iDataIndex) {
//alert("in function");
var iAge = document.getElementById('age').value * 1;
var iTripLength = document.getElementById('tripLength').value * 1;
var iAgeRangeFrom = aData[0].substr(0, aData[0].indexOf("-"));
var iAgeRangeTo = aData[0].substr(aData[0].indexOf("-") + 1, aData[0].length - aData[0].indexOf("-") - 1);
var iTripLengthFrom = aData[1].substr(0, aData[1].indexOf("-"));
var iTripLengthTo = aData[1].substr(aData[1].indexOf("-") + 1, aData[1].length - aData[1].indexOf("-") - 1);
if (iTripLength != "") {
oTable = oSettings.oInstance;
oTable.fnUpdate(aData[4] * iTripLength, iDataIndex, 6);
}
if (iAge == "" && iTripLength == "") {
return true;
}
else if (iAge == "" && (iTripLengthFrom <= iTripLength && iTripLengthTo >= iTripLength)) {
return true;
}
else if ((iAge <= iAgeRangeTo && iAge >= iAgeRangeFrom) && "" == iTripLength) {
return true;
}
else if ((iAge <= iAgeRangeTo && iAge >= iAgeRangeFrom) && (iTripLengthFrom <= iTripLength && iTripLengthTo >= iTripLength)) {
return true;
}
return false;
}
);
[/code]
This discussion has been closed.