单击 AgGrid 和 CellRenderer +单元格编辑器
我已经使用 AgGrid 创建了一个表单,任务的目标是仅对前端进行表单验证,其中前 3 个字段是强制性的,接下来的 3 个字段是可选的。
我已经使用 CellRenderer 完成了此任务 - 执行检查字段是否为空,如果为空则添加错误消息,而 CellEditor - 基本上它是输入并添加一个属性,该属性将脏状态设置为 false 显示错误消息。
以下应用程序的屏幕截图: 在此处输入图像描述
我想增强它以使用单击进行操作,因为当前用户需要单击两次以开始填充该字段,我有 singleClickEdit: true 但它不起作用,有什么想法吗?
在 codeSandbox 片段上复制了该问题: https ://codesandbox.io/s/gallant-dew-s4n8cm?file=/src/app/app.component.html
I have created a form using AgGrid, the goal of the task is to have form validation for front end only, where first 3 fields are mandatory and next 3 fields are optional.
I have done this task using CellRenderer - to perform an check if field is empty or not and add an error message if it is empty, and CellEditor - basically it is the input and adds a property that sets dirty status on false displaying the error message.
Screen shot of the app below:
enter image description here
i want to enhance it to operate using single click, as currently user needs to click twice in order to start populating the field, I have the singleClickEdit: true but it is not working, any ideas?
replicated the issue on a codeSandbox snippet: https://codesandbox.io/s/gallant-dew-s4n8cm?file=/src/app/app.component.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,此示例中发生的情况是,您在还具有自定义单元格编辑器的列上设置了
singleClickEdit=true
。由于它是一个自定义组件,因此您可以在渲染时关注输入元素。
执行此操作的一个简单方法是为输入提供 id:
然后实现单元格编辑器事件
afterGuiAttached
以关注输入:请参阅 以下示例。
So what's happening in this example is that you have
singleClickEdit=true
on a column that also has a custom cell editor.As it's a custom component, it is up to you to focus on the input element when it is rendered.
A simple way to do this is to give an id to the input:
Then implement the Cell Editor Event
afterGuiAttached
to focus on the input:See this implemented in the following sample.