How to apply sorting when adding a row as a DOM node

How to apply sorting when adding a row as a DOM node

hughgearsehughgearse Posts: 1Questions: 1Answers: 0

Hi

I have a use case where I need to add rows dynamically via javascript. I want to add the row as a dom node inline as it is what best suits my circumstances. So I am doing something like the following:

var name // String
var dob // Date
table.row.add('<tr><td>' + name + '</td><td>' + dob.format('dd-mm-yy') + '</td></tr>')

However with this approach the sorting will not be correct on the DOB field. I would need a way to tell it to sort by dob.getTime(). Is there a way I could do this?

Thanks
Des

Answers

  • kthorngrenkthorngren Posts: 21,179Questions: 26Answers: 4,923

    Try adding it as a jQuery object, like this:

    table.row.add( $('<tr><td>' + name + '</td><td>' + dob.format('dd-mm-yy') + '</td></tr>') )
    
This discussion has been closed.