Nawol
Nawol

Reputation: 81

How to get row of ui-grid based on data in single column?

I use ui-grid from http://ui-grid.info/. I've tried many things already, but the docs are confusing for me (since I started learning angular recently).

I do custom search tag system and I want to highlight the one of the rows based on user's input.

I made a plunker to make it easier for you to understand what I need to accomplish.

http://plnkr.co/edit/hSiPmhFWjHqFWpru6y13

If you fill an input with a name that matches any name in the table in First Name column, it should get the row that contains this name and make it's background red.

Upvotes: 0

Views: 436

Answers (1)

un.spike
un.spike

Reputation: 5113

first of all u should define watcher for your property or it can be handled by ng-change directive, its my working solution

<input data-ng-change="filter()" data-ng-model="filtervalue">

and inside filter function u should filter your data

$scope.mutatedSettingsCopy = [] - your data here
$scope.filter = function () {
    $scope.settings.data = $filter('filter')($scope.mutatedSettingsCopy , { $: $scope.filtervalue });
};

and on init u can set $scope.settings.data = $scope.mutatedSettingsCopy

Upvotes: 0

Related Questions