0

grid for angularjs project. I need datetime picker for the filter. So I have used angular angular-bootstrap-datetimepicker-directive for that Now my filter text box shows the datetimepicker.

But when i change the date it doesn't trigger filter change event

Here is my code:

    $scope.gridOptions = {
        paginationPageSizes  : [1],
        paginationPageSize   : 1,
        useExternalPagination: true,
        showGridFooter       : true,
        showColumnFooter     : true,
        enableFiltering      : true,
        useExternalFiltering : true,
        onRegisterApi        : function(gridApi) {
            $scope.gridApi = gridApi;

            $scope.gridApi.core.on.filterChanged($scope, function(){
                        console.log("teststs");
                angular.forEach(this.grid.columns, function(column){
                    console.log(column.filters[0].term);
                    if(column.filters[0].term)
                        $scope.searchParams[column.name] = column.filters[0].term;
                    else if(column.filters[0].term === null)
                        delete $scope.searchParams[column.name];
                });

                getPages(1, $scope.searchParams);
            });
        },
        columnDefs           : [
            { 
                field: 'createdAt',
                filterHeaderTemplate: '<div class="ui-grid-filter-container"><input type="text" id="dt1" class="form-control input-sm" datetimepicker ng-model="colFilter.term" placeholder="RAMA" name="time"></div>', 
                cellFilter: 'date: "yyyy-MM-dd"'
            },
            { 
                field: 'updatedAt', 
                cellFilter: 'date: "' + ENV.dateFormat + '"'
            }
        ]
    };

1 Answer 1

0

on the change event of the datepicker, you could add:

$scope.gridPacksApi.core.raise.filterChanged();

to force the event.

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.