Can i use jQuery templates to render the table?

Can i use jQuery templates to render the table?

MarcoAurelioMarcoAurelio Posts: 1Questions: 0Answers: 0
edited August 2011 in General
Hi, iam brazilian guy, then iam sorry my english ^^

Iam using the dataTables a lot, and I want a know if i can use jquery templates to render the table using process by server data?

ex:

[code]

oTable = $("#tbl_companyList").dataTable({
"bProcessing": true,
"bServerSide": true,
"bDestroy": true,
"bRetrieve": true,
"sAjaxSource": "../Handlers/handlerDataTables.ashx",
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function (data, textStatus, jqXHR) {
var jsonEmpresa = $.parseJSON(data.d);
$("#companyTemplate").tmpl(jsonEmpresa.listEmpresa).appendTo("#tbl_companyList tbody");
}
});
}
});

[/code]

[code]



Company:${Nome}
National register:${Cnpj}
Address:${Endereco}
Zip code:${Cep}


edit
delete







Company
Tools






[/code]

Great job for the DataTables, its is a awseome plugin ^^

Thanks.

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    You could do - but you probably wouldn't do it with server-side processing since DataTables will render the table for you already - you just give it an array of strings that you want to appear in the table and it will do it that way. The alternative is to clone the row that the template engine and then insert that into the table replacing the one that DataTables creates, which is a little more complicated, but possible :-)

    Allan
This discussion has been closed.