Skip to content

Commit

Permalink
Fix: API added data for an orthogonal HTML5 sourced table would not s…
Browse files Browse the repository at this point in the history
…how the new content in the orthogonal data's cell.

- test added
- https://www.datatables.net/forums/discussion/54118
  • Loading branch information
AllanJard committed Jan 21, 2019
1 parent 32b8b83 commit 8e01b68
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
10 changes: 6 additions & 4 deletions js/core/core.draw.js
Expand Up @@ -15,7 +15,7 @@ function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
rowData = row._aData,
cells = [],
nTr, nTd, oCol,
i, iLen;
i, iLen, create;

if ( row.nTr === null )
{
Expand All @@ -36,19 +36,21 @@ function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
{
oCol = oSettings.aoColumns[i];
create = nTrIn ? false : true;

nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
nTd = create ? document.createElement( oCol.sCellType ) : anTds[i];
nTd._DT_CellIndex = {
row: iRow,
column: i
};

cells.push( nTd );

console.log( 'create', i, create );
// Need to create the HTML if new, or if a rendering function is defined
if ( (!nTrIn || oCol.mRender || oCol.mData !== i) &&
if ( create || ((!nTrIn || oCol.mRender || oCol.mData !== i) &&
(!$.isPlainObject(oCol.mData) || oCol.mData._ !== i+'.display')
) {
)) {
nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
}

Expand Down
28 changes: 28 additions & 0 deletions test/api/rows/row.add().js
Expand Up @@ -82,4 +82,32 @@ describe('rows - row.add()', function() {
expect(isFredThere()).toBe(true);
});
});

describe('Adding new row to HTML5 attr sourced orthogonal table', function() {
dt.html('html5');

it('Add row as a Node', function() {
let table = $('#example').DataTable();
table
.row.add({
0: {
display: 'Jadzia',
'@data-filter': 'Dax'
},
1: {
display: 'Know it all',
'@data-sort': '1'
},
2: 'DS9',
3: '213',
4: '2012/03/29',
5: '0'
})
.search('Dax')
.draw();

expect($('#example tbody td:eq(0)').text()).toBe('Jadzia');
} );
});
});

0 comments on commit 8e01b68

Please sign in to comment.