Angular-DataTables custom filter

后端 未结 4 1279
旧时难觅i
旧时难觅i 2021-01-12 04:17

I am trying to add a custom filter to angular-DataTables with server side processing, which works perfectly with sorting and built in search of datatables.<

4条回答
  •  走了就别回头了
    2021-01-12 05:08

    You can use withFnServerData with fromSource functions instead of withOption:

    This API allows you to override the default function to retrieve the data (which is $.getJSON according to DataTables documentation) to something more suitable for you application.

    It's mainly used for Datatables v1.9.4. See DataTable documentation.

    $scope.dtOptions = DTOptionsBuilder.fromSource('data.json')
        .withFnServerData(serverData);
    
    function serverData (sSource, aoData, fnCallback, oSettings) {
        oSettings.jqXHR = $.ajax({
            'dataType': 'json',
            'type': 'POST',
            'url': sSource,
            'data': aoData,
            'success': fnCallback
        });
    

    :)

提交回复
热议问题