Aaron
Aaron

Reputation: 1061

AngularJS ng-table Filtering and Sorting not working

I have seen other topics on this same scenario but none of them have been able to help me fix this issue.

I using ng-table within an AngularJS application. I am able to display the data and the pagination works fine but column filtering and sorting does not work. I am able to get the filters to appear but they do not do anything.

This is what my HTML table looks like:

<table ng-table="tableParams" show-filter="true" class="paginationclass" style="width: 100%" border="1">

    <tr ng-repeat="counter in $data">
        <td data-title="'Survey Header ID'" filter="{ surveyHeader_id: 'text'}" sortable="'surveyHeader_id'">{{counter.header.surveyHeader_id}}</td>
        <td data-title="'Survey ID'" filter="{ survey_id: 'text'}" sortable="'survey_id'">{{counter.header.survey_id}}</td>
        <td data-title="'VOC Channel'" filter="{ vocChannel_name: 'select'}" filter-data="DD.vocchannels_dd" sortable="'vocChannel_name'">{{counter.header.vocChannel_name}}</td>
    </tr>

</table>

Here is ths code inside my JS controller:

    var tableParams = {
        count: 15
    };
    var tableSettings = {

    };

$http.jsonp(URL)
    .success(function (data) {
        $scope.surData = data;

        tableSettings.data = $scope.surData;
        $scope.tableParams = new NgTableParams(tableParams, tableSettings);
    }

What am I doing wrong?

Upvotes: 0

Views: 678

Answers (1)

ukn
ukn

Reputation: 1793

Ng-table sorting wont work on nested objects. Try to build your data without the header to make it looks like : counter.surveyHeader_id instead of counter.header.surveyHeader_id

Upvotes: 1

Related Questions