fnOpen, fnAddData together - example

fnOpen, fnAddData together - example

fliesflies Posts: 35Questions: 0Answers: 0
edited August 2009 in General
If someone wants to use fnOpen with fnAddData they might use this example:


Create object for html content (th is static, so we can use whole like) in td we need only the content of the cell:

[code]
var html_content = {
"exampleOptNodeTh": 'Actions',
"exampleOptNodeTd": ''
};

// we create the td node and append to visible rows (haven't checked if this will work in ajax source, probably you would net to bind the function to add columns automatically

var nCloneTd = document.createElement( 'td' );
nCloneTd.innerHTML = html_content.exampleOptNodeTd;

// we only need to do this once - no need for each
$('#example_table thead tr').prepend(html_content.exampleOptNodeTh);

$('#example_table tbody tr').each( function () {
$(this).prepend(nCloneTd);
} );

//initialize data table


// and add new row
var aoData = oTable.fnAddData( [html_content.exampleOptNodeTd,'column2','column3'] );


[/code]

this code appends the needed option content for the next cell when using fnAddData - of course there may be easier way :) Hope that someone could use it

Replies

  • allanallan Posts: 63,578Questions: 1Answers: 10,483 Site admin
    Hi flies,

    Nice one - thanks very much for sharing your code with everyone!

    Just for clarity - what is fnGetOpen()?

    Regards,
    Allan
  • fliesflies Posts: 35Questions: 0Answers: 0
    Should be fnOpen... Sorry for misspelling
  • allanallan Posts: 63,578Questions: 1Answers: 10,483 Site admin
    Ah got it! Thanks - I suspected that would be the case, but thought I better just check :-)

    Regards,
    Allan
This discussion has been closed.