Sri
Sri

Reputation: 1217

jquery datatables adding rows dynamically

I am able to add child rows to an existing table dynamically after a specific row using following datatables api :

exampletable.fnOpen( nTr, formatExampleChange(oTable, nTr), 'detailsExpand' );

Now, I wanted to have the newly added row alignment along the lines of other existing rows having same column widths.

The browser (IE, Chrome) is calculating the table TH width and it is different in different pages. (even though th widths are mentioned using sWidth:px option on all columns)

I wanted to just add a new row with same column widths. Any ideas ? I am using data tables 1.9 version

I am thinking to use nTr.getChildNodes() and then get offset width or client width of existing row and then assign the same to the newly created row columns.

But, If there is any easy way, I would like to know.

Thank you, I appreciate any help. -Sri

Upvotes: 0

Views: 604

Answers (1)

Sri
Sri

Reputation: 1217

var aoColWidths = [];

 for ( iColumn=0, iColumns=nTr.childNodes.length ; iColumn<iColumns ; iColumn++ ) {
    var colTd = nTr.childNodes[iColumn];
    aoColWidths.push( colTd.clientWidth );

 }

I have utilized above datatables api to get passed in row cols widths. and assigning these widths to newly created row cols.

Thanks!

Upvotes: 1

Related Questions