调用ngtable重新加载时,ngTable中的选择过滤器不会更新

时间:2015-09-29 12:35:41

标签: javascript angularjs ngtable

我有一种情况需要在复选框点击时显示所有数据,这会重新加载ngtable,但是选择过滤器不会加载并显示以前的值。还有其他方法可以重新加载ngtable过滤器吗?这是问题的my plunker

代码

<input id="datalabels" ng-model="taskCheckbox.isNormal" ng-change="allTaskCheckboxClicked(taskCheckbox.isNormal)" type="checkbox">
<label for="datalabels" style="font-weight:bold;">Show All Tasks</label>
<table ng-table="taskDetailTableParams" show-filter="true" class="table upgradeTaskDetailTable text-left table-bordered">
    <tbody>
        <tr ng-repeat="item in $data" height="10px" class="animate" ng-animate="{enter: 'animate-enter', leave: 'animate-leave'}">
            <td data-title="" class="text-center col-sm-1 col-md-1 col-lg-1" header-class="text-left" filter="{ 'ctaskId': 'select' }" sortable="'ctaskId'" filter-data="filterCTasks($column)">
                <img ng-src="{{ item.taskImage }}" title="{{ item.task }}" data-toggle="tooltip" data-placement="bottom" />
            </td>
            <td data-title="'Task Name'" class="text-left col-sm-3 col-md-3 col-lg-3" header-class="text-left" filter="{ 'name': 'text' }" sortable="'name'">{{ item.name }}</td>
            <td data-title="'Type of Task'" class="text-center col-sm-2 col-md-2 col-lg-2" header-class="text-left" filter="{ 'type': 'text' }" sortable="'type'">{{item.type}}</td>
            <td data-title="'latest Run'" class="text-center col-sm-2 col-md-2 col-lg-2" header-class="text-left" filter="{ 'selectIdFor0': 'select' }" sortable="'selectIdFor0'" filter-data="filterStatusFor0($column)">
                <img ng-src="{{ item.statusImageFor0 }}" title="{{ item.statusFor0 }}" data-toggle="tooltip" data-placement="bottom" />
            </td>
            <td data-title="'2nd Latest Run'" class="text-center col-sm-2 col-md-2 col-lg-2" header-class="text-left" filter="{ 'selectIdFor1': 'select' }" sortable="'selectIdFor1'" filter-data="filterStatusFor1($column)">
                <img ng-src="{{ item.statusImageFor1 }}" title="{{ item.statusFor1 }}" data-toggle="tooltip" data-placement="bottom" />
            </td>
            <td data-title="'3rd Latest Run'" class="text-center col-sm-2 col-md-2 col-lg-2" header-class="text-left" filter="{ 'selectIdFor2': 'select' }" sortable="'selectIdFor2'" filter-data="filterStatusFor2($column)">
                <img ng-src="{{ item.statusImageFor2 }}" title="{{ item.statusFor2 }}" data-toggle="tooltip" data-placement="bottom" />
            </td>
        </tr>
    </tbody>
</table>

$scope.filterCTasks = function(column) {
    console.log(JSON.stringify(column));
    var def = $q.defer(),
        arr = [],
        filterStatus = [];
    angular.forEach($scope.taskDetailData, function(item) {
        if (jQuery.inArray(item.ctaskId, arr) === -1) {
            arr.push(item.ctaskId);
            filterStatus.push({
                'id': item.ctaskId,
                'title': item.task
            });
        }
    });
    filterStatus.sort(function(a, b) {
        if (a.id < b.id)
            return -1;
        if (a.id > b.id)
            return 1;
        return 0;
    });
    def.resolve(filterStatus);
    return def;
}

0 个答案:

没有答案