0

小さな問題があります。JSONデータとして返されたクエリがあり、それをdatatables.netからデータテーブルにロードしています。0、1、または 2 の値があり、これらを yes、no、または 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 を含む列です。ありがとう :)

4

1 に答える 1

0

あなたがやろうとしていることは非常に可能性のある

参照です-DataTables.net列の使用法

var oTable = $('#test').dataTable({
    "aaData": {{ $ecl_staff }},
    "sPaginationType": "full_numbers",
    "aoColumnDefs": [ {
        "aTargets": [ 9 ],// index of the returning column
        "mRender": function ( data, type, full ) {
            if(data == 0){
                return "No";
            }
            if(data == 1){
                return "Yes";
            }
            if(data == 2){
                return "N/A";
            }
        }
    } ],
    "aoColumnDefs": [ {
        "aTargets": [ 10 ],// index of the id column
        "mRender": function ( data, type, full ) {
            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/" + data + "'></a> <a class='button icon-card with-tooltip modal_link' title='View Profile' href='{{ URL::base() }}/admin/staff/edit_staff/" + data + "'></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"
     }
});
于 2013-04-16T23:54:15.233 に答える