addTab: function() { $("#myTabs").tabs('add', { title: 'my title', closable: true, tools: [{ iconCls: 'icon-mini-refresh', handler: function() { alert('refresh'); } }] }); var currentTabPanel = $("#tabsMain").tabs('getSelected'); var dynamicTable = $('<table id="tbTest"></table>'); //这里一定要先添加到currentTabPanel中,因为dynamicTable.datagrid()函数需要调用到parent函数 currentTabPanel.html(dynamicTable); dynamicTable.datagrid({ url:'datagrid_data.json', columns:[[ {field:'code',title:'Code',100}, {field:'name',title:'Name',100}, {field:'price',title:'Price',100,align:'right'} ]] }); }