0

我在服务器端遇到数据表问题。我阅读了很多论坛,但没有得到正确的解决方案。我的问题类似这样:datatable with some custom search fields。我是这样给出的:

$(document).ready(function() {
    oTable = $('#example').dataTable();
        oTable = $('#example').dataTable({
"sDom": 'T<"clear">lfrtip',
        "bJQueryUI": true,
        "sScrollY": "450px",
                 "bScrollCollapse": true,
                 "bPaginate": true,
                 "bProcessing": true,
                 "bServerSide" : false,
        "sPaginationType": "input",
                 "sAjaxSource" : "/libclient_final/library/viewtarrif.php",
                  "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
                  oSettings.jqXHR = $.ajax( {
                 "dataType": 'json',
                 "type": "POST",
                 "url": "/libclient_final/library/viewtarrif.php",
                 "data": aoData,
                 "success": fnCallback
  } );

},

"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
                 $('td:eq(1)', nRow).html('<a href="#" data= "' + aData[1] +'view.php" title="' + aData[1] +'" class="addnew">' +
                aData[1] + '</a>');
         return nRow;
        },
                 "aoColumns": [
        { "sTitle": "<input type='checkbox' name='checkbox' id='checkbox' />", "sWidth" : "3%", "bSortable": false },
        { "sTitle": "Tariff Name", "sWidth" : "20%" },
        { "sTitle": "Currency", "sWidth" : "20%" },
        { "sTitle": "Stutus", "sClass": "center", "sWidth" : "10%" }
                ],
                   "aoColumnDefs": [
               { "sWidth": "10%", "aTargets": [ -1 ] }
               ]
            });

    $('#search').click(function(){
        oTable =  $("example").datatble({
            "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
                  oSettings.jqXHR = $.ajax( {
                 "dataType": 'json',
                 "type": "POST",
                 "url": "data.txt",
                 "data": aoData,
                 "success": fnCallback
  } )
            }

            });

})

        } );

但这段代码不起作用。我们可以使用两次 oTable 吗?请给我建议。

4

0 回答 0