简体   繁体   English

如何将自动完成功能应用于 ag-grid 的单元格?

[英]How to apply auto-complete functionality to the cell of ag-grid?

Auto-complete functionality needs to suggest function names which is in a json format and mentioned below:自动完成功能需要建议 function 名称,其格式为 json,如下所述:

{
 "id": 260,
 "title": "p_active(Power: number, PowerAngle: number)",
 "type": "PR",
 "category": "AL",
 "structure": "p_active(Power: number, PowerAngle: number)"
}

Here, p_active is a function name, which needs to be included in the suggestion.这里, p_active是一个 function 名称,需要包含在建议中。

I don't think ag-grid has support for autocomplete out of the box, with that being said there are 2 possible solutions I can think of:我认为 ag-grid 不支持开箱即用的自动完成功能,据说我可以想到两种可能的解决方案:

  1. Create a custom Cell Renderer component.创建一个自定义 Cell Renderer 组件。 This allows you to customize your cell with any component however you want, in this case what you can do is have an input there with auto complete.这允许您使用任何您想要的组件自定义您的单元格,在这种情况下,您可以做的是在那里输入自动完成。 More info about this: https://www.ag-grid.com/javascript-grid-cell-rendering-components/有关此的更多信息: https://www.ag-grid.com/javascript-grid-cell-rendering-components/

  2. Use a ready solution/package - here's a package I found: https://www.npmjs.com/package/ag-grid-autocomplete-editor使用现成的解决方案/包 - 这是我发现的 package: https://www.npmjs.com/package/ag-grid-autocomplete-editor

Here's a stackblitz with the implementation of autocomplete: https://stackblitz.com/edit/ag-grid-autocomplete-editor这是一个实现自动完成的stackblitz:https://stackblitz.com/edit/ag-grid-autocomplete-editor

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

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