虚拟滚动-有条件时启用 [英] Virtual Scroll - enabled on condition

查看:55
本文介绍了虚拟滚动-有条件时启用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理大数据表,并且如果要使用虚拟滚动或标准解决方案,则需要有机会设置动态设置.在我的原型上,我使用* ngIf并为标准正文和cdk虚拟滚动虚拟机副本视图复制了视图.是否有可能仅禁用虚拟滚动,而无需为备用视图构建其他组件?预先感谢!

I'm working on big data tables and I need to have oportunity to set dynamic if I want to use virtual scroll or standard solution. On my prototype I used *ngIf and duplicated views for standard body and cdk virtual scroll vierport. Is there any possibilty to just disable virtual scroll, without building additional components for alternate views? Thanks in advance!

推荐答案

我相信您正在根据条件添加虚拟滚动指令.在这种情况下,目前无法完成.没有方法,无法根据条件将指令添加到元素.它必须静态绑定到HTML才能定义其行为.有两种解决方法:

I believe you are asking for adding the virtual scroll directive based on a condition. In that case, it cannot be done at the moment. There is no way to add a directive to an element based on a condition. It has to be statically bound to the HTML to define it's behavior. There are 2 workarounds:

  1. 有两个不同的视图.一种是条件为真时,另一种是条件为假时.我知道这就是您现在正在做的事情.

  1. Have two different views. One when the condition is true and one when the condition is false. I understand this is what you're doing right now.

如果您是指令的作者,请将参数传递给指令以指示其不执行任何操作.不幸的是,由于您使用的是库,因此无法实现此解决方案.

If you are the author of the directive, pass an argument to the directive to instruct it to not do anything. Unfortunately since you are using a library, this solution wouldn't be possible.

请在此处查看: https://github.com/angular/angular/issues/5332

这篇关于虚拟滚动-有条件时启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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