Please, try the next code sample:
[code]
DHTMLX test
html,body {
width: 100%;
height: 100%;
margin: 0;
}
<script>
gridData={
rows:[
{ id:1001,
data:[
"100",
"A Time to Kill",
"John Grisham"] },
{ id:1002,
data:[
"1000",
"Blood and Smoke",
"Stephen King"] },
{ id:1003,
data:[
"-200",
"The Rainmaker",
"John Grisham"] },
{ id:1004,
data:[
"350",
"The Green Mile",
"Stephen King"] },
{ id:1005,
data:[
"700",
"Misery",
"Stephen King"] },
{ id:1006,
data:[
"-1200",
"The Dark Half",
"Stephen King"] },
{ id:1007,
data:[
"1500",
"The Partner",
"John Grisham"] },
{ id:1008,
data:[
"500",
"It",
"Stephen King"] }
]};
var tabbar, grid;
function doOnLoad(){
tabbar = new dhtmlXTabBar("tabbar_top", "top");
tabbar.addTab("sk","Stephen King","180px");
tabbar.addTab("jg","John Grisham","180px");
tabbar.enableContentZone(false);
// tabbar.tabs(“sk”).setActive();
mygrid = new dhtmlXGridObject('gridcontainer');
mygrid.setImagePath("../dhtmlxSuite_v41_pro/codebase/imgs/");
mygrid.setHeader("Sales, Book Title, Author");
mygrid.setInitWidths("70,250,*");
mygrid.setColAlign("right,left,left");
mygrid.setColTypes("dyn,ed,ed");
mygrid.setColSorting("int,str,str");
mygrid.init();
mygrid.parse(gridData,"json");
tabbar.attachEvent("onSelect",function(id){
if(id=="sk"){mygrid.filterBy(2,"Stephen King");}
if(id=="jg"){mygrid.filterBy(2,"John Grisham");}
return true;
});
}
</script>
</head>
<body onload="doOnLoad()">
<div id="tabbar_top" style=" height: 28px; position: relative;"></div>
<div id="m_zone" style=" height: 500px; overflow: hidden; position: relative; border-left: 1px solid #a4bed4; border-right: 1px solid #a4bed4;">
<div id="gridcontainer" style="height: 480px"></div>
</div>
</body>
[/code]