3

I am using Angular datatables (https://github.com/l-lin/angular-datatables) with server side processing, everything works fine if I didn't add the column filter But once I add the withColumnFilter option then search, pagination and records per page stop working.

Here is my HTML part:

<div class="container-fluid">
<table datatable="" dt-options="vm.dtOptions" dt-columns="vm.dtColumns" class="row-border hover">
<tfoot>
<tr>
  <th>First Name</th>
  <th>Last Name</th>
  <th>Email ID</th>
  <th>Phone Number</th>
</tr>
</tfoot>
</table>
</div>

JS Part:

(function () {
'use strict';

angular
.module('com.module.users')
.controller('UserCtrl', UserCtrl);

UserCtrl.$inject = ['$state', '$rootScope', 'ENV', 'DTOptionsBuilder', 'DTColumnBuilder'];
function UserCtrl($state, $rootScope, ENV, DTOptionsBuilder, DTColumnBuilder) {
var vm = this;

vm.currentPageState = $state.current.stateDesc;

vm.dtOptions = DTOptionsBuilder.newOptions()
  .withOption('ajax', {
    url: ENV.apiUrl + vm.currentPageState.rUrl + '/users',
    type: 'POST',
    headers: {
      Authorization: 'Bearer ' + $rootScope.globals.currentAdmin.token
    }
  })
  .withDataProp('data')
  .withOption('processing', true)
  .withOption('serverSide', true)
  .withPaginationType('full_numbers')
  .withBootstrap()
  .withColumnFilter({
    aoColumns: [{
      type: 'text',
      bRegex: true,
      bSmart: true
    }, {
      type: 'text',
      bRegex: true,
      bSmart: true
    }, {
      type: 'text',
      bRegex: true,
      bSmart: true
    }, {
      type: 'text',
      bRegex: true,
      bSmart: true
    }]
  });

vm.dtColumns = [
  DTColumnBuilder.newColumn('firstName').withTitle('First name'),
  DTColumnBuilder.newColumn('lastName').withTitle('Last name'),
  DTColumnBuilder.newColumn('email').withTitle('Email ID'),
  DTColumnBuilder.newColumn('phone').withTitle('Phone Number')
];
}

})();

After debugging what I found is ajax URL getting change to DOM URL. I have attached a screenshot for this:

Click here to see the image

4
  • 1
    Please provide details of your code. See how to ask a good question and How to create a Minimal, Complete, and Verifiable example Commented Dec 4, 2015 at 7:53
  • ... and please don't mark questions as urgent. It may be urgent to you, but to readers both now and a year down the line, it isn't urgent at all. Commented Dec 4, 2015 at 8:14
  • See github.com/l-lin/angular-datatables/issues/475. Commented Dec 4, 2015 at 15:00
  • Hi l-lin, I have checked the issue #475 where you referenced the issue to #467 but does not worked out it seems jQuery column filter does not support it. Commented Dec 7, 2015 at 8:44

1 Answer 1

0

It worked using withFnServerData instead of ajax option.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.