In AngularJS UI Grid, I receive JSON object and bind it to a grid. Now I want to filter rows based on multiple conditions from some checkboxes.
For example, I have 3 checkboxes for time:
10:00 - 12:00 -- checkbox
14:00 - 18:00 -- checkbox
20:00 - 23:00 -- checkbox
If the user clicks on the 10:00 - 12:00
and 14:00 - 18:00
checkboxes, the row should filtered based on those times.
$scope.filterGrid = function(value) {
for (int i = 0; i <= $scope.gridApi.grid.columns[2].rows.entity.length(); i++) {
// I put one condition here as an example, but in my code all of the conditions
// are included
if ($scope.gridApi.grid.columns[2].rows.entity[i].time >= "14:00" &&
$scope.gridApi.grid.columns[2].rows.entity[i].time <= "18:00") {
$scope.gridApi.grid.columns[2].filters[0]={term:value};
}
}
};
In my code, I can get what the object contains in the time ranges, but when I add objects into the grid, I only ever get last added object. For example, if I have 4 objects, the grid always show the 4th object.
I think rather than adding objects, I am overwriting them. How can I solve this problem?
Thank you for your help.
you have to change:
$scope.gridApi.grid.columns[2].filters[0]={term:value};
to:
$scope.gridApi.grid.columns[2].filters[i]={term:value};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.