如何获得NG-电网隐藏某些行 [英] How to get ng-grid to hide certain rows

查看:116
本文介绍了如何获得NG-电网隐藏某些行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我想在NG-表格显示对象的数组。每一行都有一个布尔值属性 ISVISIBLE 。在NG-网格我想只显示行,其中 ISVISIBLE 是真实的。其他行应的完全的隐藏。

I have an array of objects that I want to show in ng-grid. Each row has a boolean property isVisible. In the ng-grid I want to show only the rows where isVisible is true. The other rows should be completely hidden.

我已经尝试使用一个 rowTemplate 和数据绑定一个 NG-节目 ISVISIBLE 。隐藏行的内容,但保留实际行的地方,显示一个空行。

I have tried using a rowTemplate and databinding a ng-show to isVisible. That hides the content of the row, but leaves the actual row in place, showing an empty row.

我一直在使用filterOptions尝试过,但无法找出正确的语法做这样的过滤。我找不到如何设置任何好的文档。

I have tried using filterOptions, but can't figure out the correct syntax to do such a filtering. I couldn't find any good documentation on how to set it.

我甚至试图在NG-栅源修改 gridTemplate ,试图通过对 NG-重复= \\行添加过滤器在renderedRows \\,但我还没有得到这要么工作。

I have even tried modifying the gridTemplate in the ng-grid source, by trying to add a filter on ng-repeat=\"row in renderedRows\", but I haven't gotten that to work either.

我想我可以修改数组本身,通过暂时删除行,但我会preFER不是这样做的,因为我必须要能够再次显示行(这其实是一个扩展,我在做,这应该隐藏/显示子行)

I guess I could modify the array itself, by temporarily removing rows, but I would prefer not to do it that way, since I have to be able to show the rows again (It is actually an expander that I'm doing, that should hide/show sub-rows)

推荐答案

也尝试有条件地设置行的高度基于可见性模板'0'或使用一个CSS类纳克级。与它的CSS播放,直到你得到想要的效果,然后你可以使用你的模板。

Try also conditionally setting the height of the row in the template to '0' based on isVisible or use a CSS class with ng-class. Play with the CSS of it until you get the desired effect and then you can use that in your template.

这听起来像是将利用高度和CSS动画居然如此它打开并以动画风格关闭受益的事情的类型。如果你有一个样品的jsfiddle我很乐意尝试和帮助。

This sounds like the type of thing that would benefit from using height and CSS animations actually so it opens and closes with an animated style. If you have a jsFiddle sample I'd be happy to try and help.

编辑:仰望电网实际上是如何勾画出之后,它的行(绝对位置),你只有真正有两个选择,我能想到的:

After looking at how the grid actually lays out it's rows (absolutely positioned) you only really have two options I can think of:

1)通过像函数过滤器要绑定到网格中的数据dataVisible(),但在控制器内保持完整的数据列表,以便您可以显示/隐藏易

1) Filter the data you are binding to the grid through a function like dataVisible() but keep the full data list internally in the controller so you can show/hide easily

2)提交补丁到NG-电网项目(或者你正在寻找的过滤能力叉它)。开箱它似乎并不支持此方案。

2) Submit a patch to the ng-grid project (or fork it) with the filtering capability you are looking for. Out of the box it doesn't appear to support this scenario.

这篇关于如何获得NG-电网隐藏某些行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆