Before I rip out whats left of my hair, I ask here what 'simple' thing I am missing. I have an Infragistics igGrid where I have buttons for the user to hide (filter) some of the rows. On Infragistics forum I found this suggested code :
function hide() {
$("#igGrid").igGrid("allRows").each(function(index) {
var id = $(this).attr("colName");
// Any row with ID < 4 will be hidden
if (id < 4) {
$(this).css("display", 'none');
}
});
Looks easy, but it doesn't work. Neither does 10 more of my attempts to get the 'idCol' of the row.
What really bugs me is that in Chrome Debug, 'this' shows up as a 'tr' (in IE its a HTMLTableRowElement)!! And it has a 'cells' attribute that is an HTMLCollection ==> EXACTLY what I want! However, nothing I've tried below actually GET the value of a cell/column.
var aa = $(this).attr("colName"); // undefined
var bb = $(this); // shows in debugger as e.fn.e.init[1] ????
var cc = bb.cells[3]; // Uncaught TypeError: Cannot read property '3' of undefined
var dd = bb.getRowIndex(); // Uncaught TypeError: Undefined is not a function
var a = $(this).cells; // undefined
var b = $(this).cells[3]; // Uncaught TypeError: Cannot read property '3' of undefined
var c = $(this).getRowIndex(); // Uncaught TypeError: Undefined is not a function
var d = $(this).attributes.getNamedItem("colName"); // Uncaught TypeError: Cannot read property 'getNamedItem' of undefined
var e = $(this).attributes.colName; // Uncaught TypeError: Cannot read property 'colName' of undefined
var f = $(this).getNamedItem("colName"); // Uncaught TypeError: Undefined is not a function
var g = $(this).getAttribute("colName"); // Uncaught TypeError: Undefined is not a function
So what am I missing??
After this gets figured out, I see another problem coming. Obviously the condition for hiding rows above will not be a hardcoded '4'. In an outer onclick function I set a variable that holds the condition value. However while in this igGrid function I see that my variable is out of scope. How can I pass my variable to this 'hide()' function?