我有一个小问题。我有一个作为 JSON 数据返回的查询,我正在将其加载到 datatables.net 的数据表中。我有 0,1 或 2 的值,我想将它们更改为是、否或 n/a。
我对js一无所知,我试图实现我在网站上读到的内容,但我仍然无法让它工作。任何帮助,将不胜感激。
这就是我到目前为止所拥有的
var oTable = $('#test').dataTable({
"aaData": {{ $ecl_staff }},
"sPaginationType": "full_numbers",
"aoColumns": [
{ "mDataProp": "id" },
{ "mDataProp": "full_name" },
{ "mDataProp": "user_number" },
{ "mDataProp": "campus" },
{ "mDataProp": "email" },
{ "mDataProp": "mobile" },
{ "mDataProp": "co_ordinator" },
{ "mDataProp": "job_title" },
{ "mDataProp": "contractor" },
{ "mDataProp": "returning" },
{ "sDefaultContent": "id",
"fnRender": function (oObj) { return "<span class='button-group compact'><a class='button icon-gear with-tooltip modal_link' title='Edit user' href='{{ URL::base() }}/admin/staff/edit_staff/" + oObj.aData['id'] + "'></a> <a class='button icon-card with-tooltip modal_link' title='View Profile' href='{{ URL::base() }}/admin/staff/edit_staff/" + oObj.aData['id'] + "'></a></span>";
}
}
],
"sDom": '<"tbl_tools"CT<"clear">>,<"tbl-tools-searchbox"fl<"clear">>,<"table_content"t>,<"widget-bottom"ip<"clear">>',
"oTableTools": {
"sSwfPath": "../swf/copy_cvs_xls_pdf.swf"
},
});
$("div.tbl-tools-searchbox select").addClass('blue-gradient glossy replacement');
$("div.tbl_tools").addClass('hidden-on-mobile');
$("tfoot input").keyup( function () {
var id = $(this).attr('id').split("-")[1];
oTable.fnFilter( this.value, id );
});
,{ "mDataProp": "returning" }
数据是包含 0,1 和 2 的列。谢谢 :)