EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Onegin on July 12, 2011, 06:27:27 AM



Title: Grids within Tabs with the same ID
Post by: Onegin on July 12, 2011, 06:27:27 AM
I am using tabs, each tab having a grid as its "content". How to avoid DOM conflicts if all the grids must have the same table ID.?
I use rather tricky loop, where I update all tabs content with ' ', except the selected one, but it does not work in Firefox 4 (grid does not show the data). It does however work in FF3.6...
Any idea?


Title: Re: Grids within Tabs with the same ID
Post by: stworthy on July 12, 2011, 06:59:49 PM
Only one element may has a particular id. If two or more elements share the same id, then you cannot find the exactly element by id.
A better way is to set the class attribute to every grid, at later you can use the class selector to find them, just like this:

<table class="mytable easyui-datagrid"></table>

If you want to do some actions with the grid that displayed in selected tab panel, get the selected tab panel first and then find that grid:

Code:
var p = $('#tt').tabs('getSelected'); // get the selected tab panel
var g = p.find('table.mytable'); // get datagrid object
g.datagrid('reload'); // call datagrid method