EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on May 12, 2013, 11:18:25 PM



Title: get parent object [solved]
Post by: devnull on May 12, 2013, 11:18:25 PM
How can I EASILY (without having to manually traverse up the DOM) get the parent easyui.object ?

Examples:

1. How can I get the parent pagination object of a datagrid object ?
2. if I have a button in the pagination or tool bar how can I get the datagrid object which is it's parent ?

Thanks


Title: Re: get parent object
Post by: stworthy on May 13, 2013, 12:36:39 AM
No built-in methods can be used to find the component's parent object. To get the datagrid object from a linkbutton, you will have to get the pagination object then datagrid object.
Code:
var btn = $('#btn');  // the linkbutton in pagination
var pg = btn.closest('div.pagination');  // get the pagination object
var dg = pg.prevAll('div.datagrid-view:first').children('table');  // get the datagrid object
dg.datagrid('...');  // call some methods