简体   繁体   English

如何基于单列数据获取ui-grid行?

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

I use ui-grid from http://ui-grid.info/ . 我使用http://ui-grid.info/中的 ui-grid 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 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. 如果您填写与在表匹配任何名称的名称输入First Name列,它应该得到一个包含该名称的行,进行它的背景为红色。

first of all u should define watcher for your property or it can be handled by ng-change directive, its my working solution 首先,您应该为您的媒体资源定义观察者,否则可以通过ng-change指令来处理它,这是我的工作解决方案

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

and inside filter function u should filter your data 和内部filter功能,您应该过滤您的数据

$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 在初始化时,您可以设置$scope.settings.data = $scope.mutatedSettingsCopy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM