如何更改 Ag-grid 过滤器中的占位符文本? [英] How to change placeholder text in Ag-grid filter?

查看:27
本文介绍了如何更改 Ag-grid 过滤器中的占位符文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Ag-grid,我只想更改过滤器的占位符文本.我需要使用自定义过滤器还是也可以通过其他方式完成.请帮助

I am using Ag-grid and i just want to change placeholder text of filter.Do i need to use custom filter or this can be done via other ways as well.Please help

下面是图片链接.在其中我试图为我需要更改的占位符显示过滤器"文本.

Below is the link of image. In which i tried to show 'filter' text for placeholder which i need to change.

推荐答案

遗憾的是,默认文本过滤器的 ag-Grid 自定义选项非常差.

Unfortunately, ag-Grid customization options of the default text filter are very poor.

但是您可以通过简单的 DOM 操作来实现您的目标:

But you can achieve your goal with a simple DOM manipulation:

Array.from(document.getElementsByClassName('ag-floating-filter-input')).forEach((obj) => {
  if (obj.attributes['disabled']) { // skip columns with disabled filter
    return;
  }
  obj.setAttribute('placeholder', 'Filter...');
});

这将获取 ag-Grid(通过 'ag-floating-filter-input')类的所有过滤器文本输入并将占位符值设置为您的值.

This will grab all filter text inputs of ag-Grid (by 'ag-floating-filter-input') class and set the placeholder value to your value.

这篇关于如何更改 Ag-grid 过滤器中的占位符文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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