将 jQgrid rowid 从 iFrame 传递到主 .html 的对话框
我这里需要一些帮助。我有一个对话框,其中包含 iFrame 和 jqgrid 的 html 文件。我想要做的是,当我双击该对话框内 jqrid 中的数据时,该对话框将自动关闭,并发布在第一个对话框中单击的行的 id。
这是我的 javascript 代码:
编辑:(注意:此代码来自 subAccount.js)
$( "#mainGrid" ).click(function() { //note: mainGrid is inside of another dialog box where i should post the row id
$( "#dialogMainAccount" ).dialog( "open" ); //this is the dialog box that contains my .html with jqgrid in it.
$( "#dialogMainAccount" ).append(
'<p>Please choose code to add in Sub Account Group.</p>'+
'<iframe src="mainAccountGroup.html" width="100%" height="800">' + // i use an iFrame to open my .html file
'<p>Your browser does not support iframes.</p>' +
'</iframe>');
});
编辑: 这是我用于关闭 mainAccountGroup.js 内对话框的代码,
$("#tblData1").jqGrid({
.//some code here
.
.
caption: "Main Account Group",
ondblClickRow: function(rowid) {
parent.$("#dialogMainAccount" ).dialog("close");
....
});
我已经将 mainAccountGroup.js 包含在我的 subAccount.html 中。 注意,第一个问题解决如何在双击 jqgrid 中的一行后关闭对话框。
另一个问题是,如何将从 iFrame 中的 jqgrid 单击的 rowid 传递到第一个对话框的文本框?将值从 iframe 中的 .html 传递到主 html 中的对话框。
i need some help here. I have a dialog box that contains an iFrame with my html file of a jqgrid. What i want to do is that when I double click a data from the jqrid inside that dialog box, the dialog box will automatically close and will post the id of the row that was click in the first dialog box.
Here's my javascript code:
EDIT:(Note: this code is from subAccount.js)
$( "#mainGrid" ).click(function() { //note: mainGrid is inside of another dialog box where i should post the row id
$( "#dialogMainAccount" ).dialog( "open" ); //this is the dialog box that contains my .html with jqgrid in it.
$( "#dialogMainAccount" ).append(
'<p>Please choose code to add in Sub Account Group.</p>'+
'<iframe src="mainAccountGroup.html" width="100%" height="800">' + // i use an iFrame to open my .html file
'<p>Your browser does not support iframes.</p>' +
'</iframe>');
});
Edit: This is my code for closing the dialog box inside the mainAccountGroup.js
$("#tblData1").jqGrid({
.//some code here
.
.
caption: "Main Account Group",
ondblClickRow: function(rowid) {
parent.$("#dialogMainAccount" ).dialog("close");
....
});
I already include the mainAccountGroup.js inside my subAccount.html.
NOTE, first question solve in how to close the dialog box after double clicking a row in jqgrid.
Another question is, how to pass the rowid that was click from that jqgrid in the iFrame, to the text box of the first dialog box? Passing values from a .html in a iframe to a dialog box in the main html.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果我理解你正确的话,你可以打电话 $("#dialogMainAccount").dialog("close ") 或 $("#dialogMainAccount").dialog("destroy") 在您的 ondblClickRow 事件处理程序中jqGrid 关闭对话框。
更新:如果您希望从 iframe 中运行的代码访问变量
myVar
定义为全局(在顶层),您应该在 iframe 内部使用parent。文档
前缀:parent.document.myVar
。如果您需要从 iframe 访问主框架中定义的 HTML 元素,您应该使用
parent.document
作为 jQuery。例如$('#mainAccount',parent.document)
。If I understand you correct you can just call $("#dialogMainAccount").dialog("close") or $("#dialogMainAccount").dialog("destroy") inside of your ondblClickRow event handler of the jqGrid to close the dialog.
UPDATE: if you from the code running in the iframe want access variable
myVar
define as global (on the top level) you should use inside of iframe theparent.document
prefix:parent.document.myVar
.If you need access HTML elements defined in the main frain from the iframe you should use
parent.document
as thecontext
parameter of the jQuery. For example$('#mainAccount',parent.document)
.关于如何关闭 jqgrid 中的 ondblclick 事件的对话框的第一个问题的答案:
关于如何将值从 iFrame 传递到父 html 的第二个问题的答案:
希望这可以帮助某人
answer of my very first question on how to close the dialog box ondblclick event in jqgrid:
answer for my second question on how to pass value from an iFrame to the parent html:
hope this could help somebody