Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

Looping through columns but getting the value of another

$
0
0

Hey Alan,

I'm using the following code to loop through columns in order to create a 'header' row of sorts for items to be grouped on (I think you had posted this somewhere on the site and I snagged it, but I can't currently locate it)

api.column(10, {page:'current'} ).data().each( function ( group, i ) {
    var construct = api.row(i).data()[9];
    if ( last !== group ) {
        $(rows).eq( i ).before(
            '<tr class="construct-head"><td colspan="17" class="readonly">'+construct+'</td></tr>'
         );
    last = group;
    }
});

I'm using column 10 because it's what is unique amongst the data. Column 9 is what I actually need to show, however. The reason is that there 10 references a unique ID, but 9 references that IDs description. The problem in using 9 is that some items would be grouped that don't need to be because their other data points set them apart from one another while their descriptions do not.

How can I access the row's data to grab data()[9]? When I use dt.rows(i).data() it's grabbing another one, seemingly, than the one the current column() is looping through because the group value and data()[9] are not the same.

Thanks for any assistance


Viewing all articles
Browse latest Browse all 2364

Trending Articles