【发布时间】:2013-04-16 08:16:05
【问题描述】:
我有一个小问题。我有一个作为 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 的列。
谢谢:)
【问题讨论】:
-
在数据表中使用数据之前更改数据不是更容易吗?
-
嗨,是的,但我的 mysql 技能不是那么好。当我阅读 mysql 中的 if 语句时,它提到了一些我没有做的存储过程。谢谢