using html attributes to set settings like aoColumDefs

using html attributes to set settings like aoColumDefs

jerry1970jerry1970 Posts: 12Questions: 0Answers: 0
edited February 2012 in General
Hi all,

Maybe this is more general javascript than jquery or datatables, but I am trying to read html attributes and pass them to the datatable. For example, I would like to have this:

[code]




ID
Account
Address 1
Address 2
Zip code
City
Country
Site








[/code]

I couldn't find anything to make this work, but unsuccessfully. So I tried this:

[code]




...

[/code]
and then have this in javascript:
[code]
var aoColumnDefs = [];
var aTargets = [];
jQuery( ".dropdowntotable_col_hidden" ).each( function( ix ) {
aTargets.push( jQuery(this).attr( "col" ) );
} );
aoColumnDefs.push( { "bVisible" : false, "aTargets": aTargets } );

aTargets = [];
jQuery( ".dropdowntotable_col_nosort" ).each( function( ix ) {
aTargets.push( jQuery(this).attr( "col" ) );
} );
aoColumnDefs.push( { "bSortable" : false, "aTargets": aTargets } );

jQuery( "#mytable" ).dataTable( {
"aoColumnDefs" : aoColumnDefs
} );
[/code]

This doesn't work... I get a little confused by the arrays in curly braces and brackets.
Any help is much appreciated!

Thanks!
Jerry

br

Replies

  • jerry1970jerry1970 Posts: 12Questions: 0Answers: 0
    Hm... this seems to help:
    [code]
    parseInt( jQuery(this).attr( "col" ) )
    [/code]
This discussion has been closed.