开发者

Passing jQgrid rowid from an iFrame to the dialog box of the main .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 开发者_Go百科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.


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 the parent.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 the context parameter of the jQuery. For example $('#mainAccount',parent.document).


answer of my very first question on how to close the dialog box ondblclick event in jqgrid:

$("#tblData1").jqGrid({
    .//some code here
    .
    .
    caption: "Main Account Group",
    ondblClickRow: function(rowid) {
       parent.$("#dialogMainAccount" ).dialog("close"); //use parent since the dialog box is from the parent html
    ....
}); 

answer for my second question on how to pass value from an iFrame to the parent html:

parent.$('#mainAccount').val(rowid);   // the $('#mainAccount') in from the parent html.

hope this could help somebody


$('jqgridId').parents('#dialogId').remove();

$('jqgridId').parents('#dialogId').dialogr('close');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜