Jqgrid,dataEvent 不适用于 edittype:custom
我是 jqgrid 的新手,我有一个编辑类型是自定义的列。
编辑行数据后,我希望该行保存为模糊状态(当我单击所选行外部时),为此我使用了 dataEvent ,但它不起作用。
我使用的是 Jqgrid 版本4.1。
有人可以帮我解决这个问题吗?
我在下面附上了一段代码:
{ name: 'Roles', index: 'Roles', align: 'left', editable: true,
edittype: "custom",
editoptions: {custom_element: renderRoleColumn, custom_value: roleColumnValue,
dataEvents: [{ type: 'blur',
fn: function (e) {
alert("roles");
}
}]
}
}
I'm new to jqgrid, I have a column whose edit type is custom.
Once the row data is edited , I want the row to be saved on blur (when i click outside of the selected row), for this purpose i made use of dataEvent , but it does not work.
I'm using Jqgrid version4.1.
Can someone please help me to resolve this issue.
I have attached a piece of my code below:
{ name: 'Roles', index: 'Roles', align: 'left', editable: true,
edittype: "custom",
editoptions: {custom_element: renderRoleColumn, custom_value: roleColumnValue,
dataEvents: [{ type: 'blur',
fn: function (e) {
alert("roles");
}
}]
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是对的。 jqGrid 的当前实现不使用
dataInit
或dataEvents
(请参阅 jqGrid源码不调用options = bindEv(elem,options)
就像所有其他编辑类型一样)。问题只是我不确定这是一个错误。在 jqGrid 的文档中,实际上描述了所有步骤在edittype: "custom"
的情况下完成。我不认为这是一个问题。您可以在
custom_element
内部进行任何绑定。您没有发布任何您使用的renderRoleColumn
和roleColumnValue
代码,但如果您将blur
事件句柄绑定到您使用的自定义元素返回后即可工作。更新:您的自定义格式化程序
renderRoleColumn
返回,其中包含
和
。代码可以像下面这样
You are right. The current implementation of jqGrid don't use
dataInit
ordataEvents
on the (see the source code of jqGrid don't calloptions = bindEv(elem,options)
like for all other edittypes). The problem is only that I am not sure that it's a bug. In the documentation of jqGrid described really all steps which are done in case ofedittype: "custom"
.I don't see that it's a problem. You can make any bindings inside of
custom_element
. You don't posted any code ofrenderRoleColumn
androleColumnValue
which you use, but if you would bindblur
event handle to the custom element which you returned it will be work.UPDATED: Your custom formatter
renderRoleColumn
returns<div>
with<select>
and<input>
elements as children. The<div>
can't have focus and will don't processblur
event too. So you should bindblur
to the child elements<select>
and<input>
. The code can be like the following