Datatables plugin - how to create <td> attributes when calling fnAddData() to create table rows
Hello,
Prior to trying out Datatables, I basically created my Html table manually and used jQuery .appendTo() to add the rows. It was quite fast.
For example:
- $(this).find("exposureProfile node").each(function () {
- // init vars here...
- myRow = "<tr><td class='td_pfid'>" + pfId + "</td>";
- myRow += "<td class='td_nodedate'>"+ nodeDate + "</td><td>" + term +
- "</td><td align=right>" + exposure + "</td></tr>";
- // add more rows to myRow
- $(myRow).appendTo("#pftable"); // APPEND TO MY TABLE USING STANDARD JQRY !
- }
Now I'm trying to retrofit Datatables and therefore dynamically add the rows using fnAddData(), and noticed it's much slower using fnAddData(). It does work but slowly
Bigger question: How do I specify the attributes of my <td> cells when calling into fnAddData() API, for example <td class='td_pfid'> .
I need this because I have a click event on the <tr> rows which searches for these attributes :
- $("#pftable tbody tr").click(function (event) {
- ...
- var thisPfId = $(this).find('.td_pfid').text(); // Find Portfolio Id and Node Date !!
var thisDate = $(this).find('.td_nodedate').text();
- ...
- }
Of course, I'd like to speed the table rendering up a bit, but I first need to figure out how to create attribues in my <td> elements.
Thanks ahead of time for your responses !
Regards,
Bob