jqgridでは、カスタムフォーマッタ関数を使用できます。この関数では、特定の列で使用するhtml文字列テンプレートを返します(http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter)。
Datatable(およびjqGridでも)には、既存の要素からグリッドを作成するオプションがあります。その場合、あなたはカミソリの@foreach文を使用してテーブルを作成し、セル内にテンプレートを適用することができます。
jqgridカスタムフォーマッタとjqueryテンプレートを使用する例:
// Your cell template
<script id="MyColumnTemplate" type="text/x-jquery-tmpl">
${Name}
</script>
<script>
// creating the grid passing the formating function
$('#GridView').jqGrid({
(...)
colModel: [
{ name: 'Custom', formatter: myFormatter}, ...],
});
});
function myFormatter(cellvalue, options, rowObject) {
var data = { Name: 'Test' };
//applying the jQuery template and returning html output
return $('#MyColumnTemplate').tmpl(data).html();
}
</script>