EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: sky-t on May 20, 2017, 12:24:46 AM



Title: Access Datagrid in iframe
Post by: sky-t on May 20, 2017, 12:24:46 AM
I want to append / delete rows in a datagrid that is located in an iframe.
I cann access and manipulate other dom objects in that iframe but not the datagrid

Code:
var table_cc=$("#iframe").contents().find("#dg");

if (table_cc != undefined) {
console.log(table_cc);
table_cc.datagrid('appendRow',{
name: 'from socket',
code: 'inforo'
});
}


How can we solve this?


Title: Re: Access Datagrid in iframe
Post by: sky-t on May 21, 2017, 09:25:00 PM
any ideas?


Title: Re: Access Datagrid in iframe
Post by: jarry on May 22, 2017, 06:33:28 PM
Define a function in your iframe.
Code:
function appendRow(){
$('#dg').datagrid('appendRow', {
name:'from socket',
code:'inforo'
})
}

And then call this function in your top window.
Code:
window.frames['iframe'].appendRow();


Title: Re: Access Datagrid in iframe
Post by: sky-t on May 22, 2017, 10:28:21 PM
Hi jarry,

this is working! Thank you so much!!!