ExtJS 4 - 如何有条件地编辑网格中的单元格?
我有一个使用单元格编辑插件的网格面板。
在此网格面板中,我希望通过以下方式对单元格进行条件编辑:
当用户单击单元格进行编辑时,应该显示确认对话框 - “您想编辑单元格吗?” - 如果他选择“是”,则单元格将获得焦点并开始编辑,否则单元格将保持禁用状态。
我尝试过使用“beforeedit”事件,但即使显示确认框,用户也可以使用箭头键修改值(因为编辑器是数字字段),也就是说,尽管禁用了鼠标单击,但是箭头键仍然可以更改字段的值。
另外,当用户选择“是”时,单元格会失去焦点,并且我无法使其在单击“是”后立即开始编辑。我尝试过使用“焦点”方法,但没有成功。
有人可以指导一下吗?
提前致谢。
更多信息:
当用户选择“是”时,我尝试使用 - startEditByPosition() - 单元格编辑插件的功能。但是,由于这个原因,确认框不断出现,因为选择“是”时编辑开始,再次调用 beforeedit 事件。有什么帮助吗?
I have a grid panel using cell editing plugin.
In this grid panel, I want conditional editing on a cell in following manner:
When a user clicks on the cell to edit, there should be confirm dialog shown - "Do you want to edit the cell?" - if he chooses 'Yes' then the cell is focussed and editing begins otherwise the cell remains disabled.
I have tried using 'beforeedit' event, but the user is able to modify the values using the arrow keys (as the editor is a numberfield) even when the confirm box is being displayed, that is, though the mouse-click is disabled but arrow keys can still change the value of the field.
Also, when the user chooses 'Yes' then the cell looses focus and I am not being able to make it begin edit right after 'Yes' click. I have tried using 'focus' method but no luck.
Could some guide at this?
Thanks in advance.
More Information:
I tried using - startEditByPosition() - function of cell editing plugin when user chooses 'Yes'. But then, due to this, the confirm box keeps appearing back, as on choosing 'Yes' editing starts which call the beforeedit event again. Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建一些标志变量,例如
isEditAllowed
。在beforeedit
中检查它。如果为 false,则显示confirm
,否则不执行任何操作。如果用户确认将isEditAllowed
设置为true
和startEditByPosition
。在edit
事件中将isEditAllowed
设置为false
:这是演示。
You can create some flag variable like
isEditAllowed
. Check it inbeforeedit
. If it is false showconfirm
else do nothing. If user confirms setisEditAllowed
totrue
andstartEditByPosition
. Inedit
event setisEditAllowed
tofalse
:Here is demo.