How to supply data to datatable with extra styling?

How to supply data to datatable with extra styling?

kamikzkamikz Posts: 2Questions: 0Answers: 0
edited June 2012 in DataTables 1.9
Hi there, I know that datatable supports initializing from an array of values or from an already on-page HTML rows. I have been using the latter method because I need the flexibility to add styling to and add other elements in the cells. If I had used array of values to initialize the table, I would only have something like

HomerSimpson

instead of what I want

HomerSimpsonui-icon

But now whenever I want to add data after the datatable has been initialized, if I don't use the fnAddData() method and just use some jquery append method to add table rows, all these newly manually added the .. 1) won't have the alternating color, 2) won't get sorted. and so on. it is as if it doesn't really belong to the datatable. And when I click on any of the sortable , these newly manually added rows disappear altogether(!)

Can someone suggest a way for me to add data to the table NOT using the fnAddData() method?

Thank You!

Replies

  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin
    Hi,

    This FAQ is relevant here: http://datatables.net/faqs#append .

    Basically you have to use the DataTables API, however, if you have already created the TR element, you could look at using the fnAddTr plug-in: http://datatables.net/plug-ins/api#fnAddTr . Its like fnAddData, but takes a TR node.

    Allan
This discussion has been closed.