列过滤器使搜索值搜索= [对象对象]

时间:2016-03-29 05:21:35

标签: datatables angular-datatables

搜索正在查找,但当我尝试使用列过滤器时,搜索值更改为search=[object Object]

完整网址:http://localhost:8000/locations/?draw=2&columns=[object Object],[object Object],[object Object]&order=[object Object]&start=0&length=10&search=[object Object]&sRangeSeparator=~

HTML

<div ng-controller="ServerSideProcessingCtrl as showCase">
        <table class="row-border hover table table-condensed table-hover" dt-columns="showCase.dtColumns" dt-options="showCase.dtOptions" datatable="">
          <thead>
            <tr>
              <th>ID</th>
              <th>Company</th>
              <th>Location</th>
            </tr>
            <tr>
              <th>ID</th>
              <th>Company</th>
              <th>Location</th>
            </tr>
          </thead>
        </table>
      </div>

JS

angular.module('myApp', ['datatables',  'datatables.columnfilter'])
            .controller('ServerSideProcessingCtrl', ServerSideProcessingCtrl);

    function ServerSideProcessingCtrl(DTOptionsBuilder, DTColumnBuilder) {
      var vm = this;
      vm.dtOptions = DTOptionsBuilder.newOptions()
              .withFnServerData(serverData)
              .withOption('source', 'http://localhost:8000/locations/')
              .withOption('processing', true)
              .withOption('serverSide', true)
              .withPaginationType('full_numbers')
              .withDataProp('data')
              .withColumnFilter({
                sPlaceHolder: "head:after",
                aoColumns: [{
                  type: 'number'
                }, {
                  type: 'text',
                  bSmart: true
                }, {
                  type: 'text',
                  bSmart: true
                }]
              });

      function serverData(sSource, aoData, fnCallback, oSettings) {
        sSource = "http://localhost:8000/locations/";
        oSettings.jqXHR = $.ajax( {
          "dataType": 'json',
          "type": "GET",
          "url": sSource,
          "data": aoData,
          "success": function(json){
            json.draw = 1;
            json.recordsTotal = json.count;
            json.recordsFiltered = json.count;
            json.data = json.results;
            fnCallback(json);
          },
          "error": function (e) {
            console.log(e.message);
          }
        });
      }

      vm.dtColumns = [
        DTColumnBuilder.newColumn('id').withTitle('ID'),
        DTColumnBuilder.newColumn('company_name').withTitle('Company'),
        DTColumnBuilder.newColumn('name').withTitle('Location')
      ];
    }

JSON数据

{
    "count": 205,
    "results": [
        {
            "id": 1,
            "companies": 2,
            "company_name": "RRBRO Softwares",
            "name": "Davao"
        },
        {
            "id": 2,
            "companies": 2,
            "company_name": "RRBRO Softwares",
            "name": "Panabo"
        },
       ...
   ]
}

0 个答案:

没有答案