在 JQGrid 中我想添加一个不回发的行按钮
即使我在按钮的 onclick 方法中指定不这样做(onclick=' return false;'),我添加到行中的按钮仍然会回发。我想是网格在回发?我试图阻止回发并显示我自己的自定义弹出表单。
gridComplete: function(){
var ids = $('#jqGridControl1').jqGrid('getDataIDs');
for(var i=0;i < ids.length;i++){
var rowid = ids[i];
de = "<input type='image' title='Delete this record.' src='../images/icn_delete.gif' onclick=' return false;' style='border-width:0px;'/>";
ee = "<input type='image' title='Edit this record.' src='../images/icn_edit.gif' onclick=' return false;' style='border-width:0px;' />";
ve = "<input type='image' title='View related information.' src='../images/house.gif' onclick='return false;' style='border-width:0px;' />";
pe = "<input type='image' title='Print' src='../images/icn_printer.gif' onclick=' return false;' style='border-width:0px;' />";
je = "<input type='image' title='Appointment' src='../images/icn_journal.gif' onclick=' return false;' style='border-width:0px;' />";
se = "<input type='image' title='Select' src='../images/icn_select.gif' onclick=' return false;' style='border-width:0px;' />";
jQuery('#jqGridControl1').jqGrid('setRowData',ids[i],{act:de+ee+ve+pe+je+se});
}
The buttons I have added to the rows still post back even if I specifiy not to do so in the onclick method of the button (onclick=' return false;'). I supose its the grid doing the post back? I am tring to prevent the postback and show my own custom popup forms.
gridComplete: function(){
var ids = $('#jqGridControl1').jqGrid('getDataIDs');
for(var i=0;i < ids.length;i++){
var rowid = ids[i];
de = "<input type='image' title='Delete this record.' src='../images/icn_delete.gif' onclick=' return false;' style='border-width:0px;'/>";
ee = "<input type='image' title='Edit this record.' src='../images/icn_edit.gif' onclick=' return false;' style='border-width:0px;' />";
ve = "<input type='image' title='View related information.' src='../images/house.gif' onclick='return false;' style='border-width:0px;' />";
pe = "<input type='image' title='Print' src='../images/icn_printer.gif' onclick=' return false;' style='border-width:0px;' />";
je = "<input type='image' title='Appointment' src='../images/icn_journal.gif' onclick=' return false;' style='border-width:0px;' />";
se = "<input type='image' title='Select' src='../images/icn_select.gif' onclick=' return false;' style='border-width:0px;' />";
jQuery('#jqGridControl1').jqGrid('setRowData',ids[i],{act:de+ee+ve+pe+je+se});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过更多的研究后,我发现它可以在 FF 和 Safari 中工作。问题出在IE上。而不是仅仅 onclick='return false;'我将其更改为 onclick='event.returnValue=false;返回假;'这奏效了。不知道为什么会这样。如果我用 HTML 编写输入标签并使用 onclick='return false;'效果很好。不知道为什么当这些行是在客户端动态生成时会有所不同。
After some more work on this I figured out that it worked in FF and Safari. The issue was IE. Instead of just onclick='return false;' I changed it to onclick='event.returnValue=false; return false;' and that worked. Not sure why that is. If I have the input tag written in HTML with onclick='return false;' it works fine. Not sure why its different when the lines are generated on the fly at the client.