I am currently working on an Angular application that utilizes ui-grid for displaying data, and I want to implement filters for each column. I have already successfully implemented a search feature for the entire table. Here is my HTML code:
<div class="col-md-12" ng-controller="FlatController as flat">
<div class="search-wrapper">
<div class="search-box">
<input type="text" class="form-control" ng-model="flat.searchText" ng-change="flat.refreshData()" placeholder="Search...">
</div>
</div>
<div class="ui-grid-wrapper">
<div ui-grid="flat.gridOptions" ui-grid-resize-columns ui-grid-auto-resize id="grid1" class="grid"></div>
</div>
</div>
Here is the controller code:
angular.module('flatCtrl', ['flatService', 'ngTouch', 'ui.grid', 'ui.grid.resizeColumns', 'ui.grid.moveColumns', 'ui.grid.autoResize', 'ngSanitize', 'ui.select', 'ui.date'])
.controller('FlatController', ['Flat', 'socketio', '$filter', function(Flat, socketio, $filter){
vm = this;
Flat.allFlat()
.success(function(data){
vm.flats = data;
vm.gridOptions = {
data: data,
columnDefs: [
{field: 'id', displayName: 'Id', visible: false},
{field: 'creator', displayName: 'Creator', visible: false},
{field: 'typelocal', displayName: 'Typ lokalu', visible: true},
{field: 'country', displayName: 'Kraj', visible: true},
{field: 'city', displayName: 'Miejscowość', visible: true},
{field: 'district', displayName: 'Dzielnica', visible: true}
]
};
vm.refreshData = function() {
vm.gridOptions.data = $filter('filter')(vm.flats, vm.searchText, undefined);
};
});
Can anyone advise me on how to add input fields in my HTML for each column in the ui-grid?