Arrange jQuery Widgets or HTML elements with Dock Layout Panel

The jqxDockPanel widget represents a container for other widgets or html elements. It arranges its inner elements depending on the value of the ‘dock’ attribute. The possible ‘dock’ attribute values are: ‘left, right, top and bottom’. Lets take a look at the following HTML structure:
<div id='jqxDockPanel' style="background: none; border: none;">
<div id='top' style="height: 50px;" dock='top'>
<div id="menu">
<ul>
<li>Menu Item 1
<ul>
<li>Sub Item 1</li>
<li>Sub Item 2</li>
<li>Sub Item 3</li>
</ul>
</li>
<li>Menu Item 2</li>
<li>Menu Item 3</li>
<li>Menu Item 4</li>
<li>Menu Item 5</li>
<li>Menu Item 6</li>
</ul>
</div>
</div>
<div id='bottom1' style="height: 50px; background: #dfdfdf;" dock='bottom'>
Bottom 1</div>
<div id='bottom2' style="height: 50px; background: #efefef;" dock='bottom'>
Bottom 2</div>
<div style="width: 50px; background: #dfdfdf;" dock='right'>
Right Panel</div>
<div style="width: 50px; background: #dfdfdf;" dock='left'>
Left Panel</div>
<div id='content'>
<div id='jqxNavigationBar'>
<!--Header-->
<div>
Early History of the Internet</div>
<!--Content-->
<div style="overflow: auto;">
<ul>
<li>1961 First packet-switching papers</li>
<li>1966 Merit Network founded</li>
<li>1966 ARPANET planning starts</li>
<li>1969 ARPANET carries its first packets</li>
<li>1970 Mark I network at NPL (UK)</li>
<li>1970 Network Information Center (NIC)</li>
<li>1971 Merit Network's packet-switched network operational</li>
<li>1971 Tymnet packet-switched network</li>
<li>1972 Internet Assigned Numbers Authority (IANA) established</li>
<li>1973 CYCLADES network demonstrated</li>
<li>1974 Telenet packet-switched network</li>
<li>1976 X.25 protocol approved</li>
<li>1979 Internet Activities Board (IAB)</li>
<li>1980 USENET news using UUCP</li>
<li>1980 Ethernet standard introduced</li>
<li>1981 BITNET established</li>
</ul>
</div>
<!--Header-->
<div>
Merging the networks and creating the Internet</div>
<!--Content-->
<div>
<ul>
<li>1981 Computer Science Network (CSNET)</li>
<li>1982 TCP/IP protocol suite formalized</li>
<li>1982 Simple Mail Transfer Protocol (SMTP)</li>
<li>1983 Domain Name System (DNS)</li>
<li>1983 MILNET split off from ARPANET</li>
<li>1986 NSFNET with 56 kbit/s links</li>
<li>1986 Internet Engineering Task Force (IETF)</li>
<li>1987 UUNET founded</li>
<li>1988 NSFNET upgraded to 1.5 Mbit/s (T1)</li>
<li>1988 OSI Reference Model released</li>
<li>1988 Morris worm</li>
<li>1989 Border Gateway Protocol (BGP)</li>
<li>1989 PSINet founded, allows commercial traffic</li>
<li>1989 Federal Internet Exchanges (FIXes)</li>
<li>1990 GOSIP (without TCP/IP)</li>
<li>1990 ARPANET decommissioned</li>
</ul>
</div>
<!--Header-->
<div>
Popular Internet services</div>
<!--Content-->
<div>
<ul>
<li>1990 IMDb Internet movie database</li>
<li>1995 Amazon.com online retailer</li>
<li>1995 eBay online auction and shopping</li>
<li>1995 Craigslist classified advertisements</li>
<li>1996 Hotmail free web-based e-mail</li>
<li>1997 Babel Fish automatic translation</li>
<li>1998 Google Search</li>
<li>1999 Napster peer-to-peer file sharing</li>
<li>2001 Wikipedia, the free encyclopedia</li>
<li>2003 LinkedIn business networking</li>
<li>2003 Myspace social networking site</li>
<li>2003 Skype Internet voice calls</li>
<li>2003 iTunes Store</li>
<li>2004 Facebook social networking site</li>
<li>2004 Podcast media file series</li>
<li>2004 Flickr image hosting</li>
<li>2005 YouTube video sharing</li>
<li>2005 Google Earth virtual globe</li>
</ul>
</div>
</div>
</div>
</div>
The above markup has one container DIV tag which we will call DockPanel and 6 nested DIV tags with additional html elements inside. Five of the nested DIV tags has a special attribute called – dock. The dock attribute is used by the jqxDockPanel widget to specify the DIV tag’s position inside the DockPanel. The last DIV tag with id=”content” does not have a dock attribute. It will be the DockPanel’s content and will fill the remaining available space. Now, lets see how to add the jqxMenu and jqxNavigationBar inside the DockPanel. At first, we need to include the javascript and css files in the Head section of our page.
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.classic.css" type="text/css" />
<script type="text/javascript" src="../../scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxdockpanel.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxexpander.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxnavigationbar.js"></script>
Next, we initialize the jqxMenu, jqxNavigationBar and jqxDockPanel widgets by using the code below:
<script type="text/javascript">
$(document).ready(function () {
$("#menu").jqxMenu({ height: 50, theme: 'classic' });
$("#jqxNavigationBar").jqxNavigationBar({ width: 500, height: 250, sizeMode: 'fitAvailableHeight', theme: 'classic' });
$("#jqxDockPanel").jqxDockPanel({ width: 600, height: 400 });
});
</script>
The resulting layout is displayed below: jquery-dock-layout

About admin


This entry was posted in JavaScript, JavaScript Plugins, JavaScript UI, JavaScript UI Plugins, JavaScript UI Widgets, JavaScript Widgets, jQuery, jQuery Plugins, jQuery UI, jQuery UI Plugins, jQuery UI Widgets, jQuery Widgets, jQWidgets and tagged , , , , , , , , , , , , , , , , . Bookmark the permalink.



Leave a Reply