Here you go.
onClick: function (event) {
switch (event.target)
{
case 'tab1': w2ui['layout'].content('main', w2ui.grid1); break;
case 'tab2': w2ui['layout'].content('main', w2ui.grid2); break;
}
}
and full page
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://w2ui.com/src/w2ui-1.5.rc1.min.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="http://w2ui.com/src/w2ui-1.5.rc1.min.js"></script>
</head>
<body>
<div id="layout" style="width: 100%; height: 250px;"></div>
<script>
$(function () {
// load grid into memory
$().w2grid({
name: 'grid1',
columns: [
{ field: 'fname', caption: 'First Name', size: '180px' },
{ field: 'lname', caption: 'Last Name', size: '180px' },
{ field: 'email', caption: 'Email', size: '40%' },
{ field: 'sdate', caption: 'Start Date', size: '120px' }
],
records: [
{ recid: 1, fname: 'John', lname: 'Doe', email: '[email protected]', sdate: '4/3/2012' },
{ recid: 2, fname: 'Stuart', lname: 'Motzart', email: '[email protected]', sdate: '4/3/2012' }
]
});
$().w2grid({
name: 'grid2',
columns: [
{ field: 'state', caption: 'State', size: '80px' },
{ field: 'title', caption: 'Title', size: '100%' },
{ field: 'priority', caption: 'Priority', size: '80px', attr: 'align="center"' }
],
records: [
{ recid: 1, state: 'Open', title: 'Short title for the record', priority: 2 },
{ recid: 2, state: 'Open', title: 'Short title for the record', priority: 3 },
{ recid: 3, state: 'Closed', title: 'Short title for the record', priority: 1 }
]
});
var pstyle = 'background-color: #F5F6F7; border: 1px solid #dfdfdf; padding: 5px;';
$('#layout').w2layout({
name: 'layout',
panels: [
{ type: 'top', size: 50, resizable: true, style: pstyle, content: 'top' },
{ type: 'left', size: 200, resizable: true, style: pstyle, content: 'left' },
{ type: 'main', style: pstyle,
tabs: {
name: 'tabs',
active: 'tab1',
tabs: [
{ id: 'tab1', text: 'Tab 1' },
{ id: 'tab2', text: 'Tab 2' }
],
onClick: function (event) {
switch (event.target)
{
case 'tab1': w2ui['layout'].content('main', w2ui.grid1); break;
case 'tab2': w2ui['layout'].content('main', w2ui.grid2); break;
}
}
}
},
{ type: 'preview', size: '50%', resizable: true, style: pstyle, content: 'preview' },
{ type: 'right', size: 200, resizable: true, style: pstyle, content: 'right' },
{ type: 'bottom', size: 50, resizable: true, style: pstyle, content: 'bottom' }
]
});
w2ui['layout'].content('main', w2ui.grid1);
});
</script>
</body>
</html>