Monday, January 28, 2013

JQuery DataTables - add id attribute to each row




"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull) {
   $(nRow).attr("id",aData.userid);
   return nRow;
 }

this is example data returned from server:

[{"userid":"wx","password":"wx1","timeStamp":1358999302000,"checked":1},{"userid":"u7","password":"p7","timeStamp":1358912639000,"checked":1},{"userid":"u5","password":"p5","timeStamp":1358836704000,"checked":1},{"userid":"rr","password":"ee","timeStamp":1359343559000,"checked":1},{"userid":"ds","password":"a","timeStamp":1358911426000,"checked":1},{"userid":"bdsdc","password":"dbdsa","timeStamp":1359343572000,"checked":1},{"userid":"bdc","password":"dbdsa","timeStamp":1359343496000,"checked":1},{"userid":"bc","password":"dbdsa","timeStamp":1359342034000,"checked":1},{"userid":"a1","password":"a","timeStamp":1359012297000,"checked":0}]

this is the actual result of the tables shown on page:

<tr class="odd" id="a1"><td class=" sorting_1">a1</td><td class="">a</td><td class="">1359012297000</td><td class=""><input type="checkbox" name="aCheckBox" class="dt_checked" value="0"></td><td class="center"><a href="" class="editor_remove">Delete</a></td></tr>

No comments:

Post a Comment