Table of Contents
What is a drilldown and how does it work in javascript
If you’re a designer adding drilldown functionality to your pages, you’ll probably want to use one of the libraries available. There are many JavaScript libraries which have been created for this purpose. Some are built on top of other JavaScript libraries, so it’s a matter of choosing the one that will work best for your situation. This article explains the basics of a drilldown and the process of creating it.
What is a Drilldown?
A drilldown is a feature in which, when the user hovers their mouse over an element on your page, they are shown an alternative view on the same page – usually with additional information related to their original spot on the page. The alternative view can be a separate page or it can be part of the original page (if you scroll down to see it as well). The element which triggers the extra information is called a drilldown trigger.
Basic Drilldown

Creating an interactive drilldown using React
As an alternative to a library, you can do the same thing using React.js and JSX. This is something I created for a demo, but it isn’t particularly well-tested code so I’m not putting it up on GitHub. If you’re curious, you can view the codepen to see what it looks like: https://codepen.io/chrismcintyre/pen/BKpGHY
##
Introduction to React and JSX [to create the app]
1. Create a file called helloworld.js and include:
2. Create another file called index.js, in which includes helloworld, and import it: (in the browser console) helloworld = require(“helloworld”); (in nodejs console) var helloworld = require(“helloworld”); and then export the main component as index.jsx: var Example = React.createClass({ render: function() { return ( React.createElement(“h1”, {}, “Hello World”) ); } }); module.exports = Example;
3. Then, in the browser, create an index.html file with the following:
You'll want to be able to write JSX in the browser console too, so you'll get a file called test.jsx in the project directory:

Adding functionality to the drilldown
If you want your drilldown to act like a normal dropdown, there are a couple of options. An easy way is to use the jQuery plugin from https://github.com/mattrayner/jquery-drilldown . This plugin uses HTML5 data attributes and makes it easy to add interactive functionality. Just add a data-drd=true attribute to your list item and it'll work.
- I've been working on a tool to help us bring this functionality to your site, but as I mentioned in my last article on the subject, it's still in an early alpha stage. You can install it by clicking the link below and follow the installation instructions: "jquery-drilldown".
It may take some time for me to get back to you with some recommendations, but I hope you find this useful.
Cheers,
Brendan Kearns
Head of Digital Strategy at Common Purpose, Hong Kong
"javascript drilldown" : "Adding functionality to the drilldown" [ARTICLE END] .

Styling the drilldown
Styling a drilldown is similar to styling a standard dropdown. You can add a number of styles to the background and edge classes. It may be a good idea to style the header area differently too to make the user interface clear and easy to understand.
I said that styling a drilldown is similar to styling a standard dropdown, but there are differences. Let's look at some of them:

Demo and source code
The demo is available on GitHub, and the source code is available at https://github.com/chrismcintyre/javascript-drilldown , along with instructions for installing it in your project. The source code is a little bit messy, so if you have questions about it, please ask them in the comments section at the bottom of this page.
In this demo, a drilldown is achieved by adding the attribute data-drilldown="true" to a links of type button or a tags placed within an element with the attribute data-controlgroup="true" . The link or tag has to be within the section [mydata].
The opening link tag is wrapped in a nav with the data-controlgroup attribute. The nav must contain links of type button . It may optionally contain links of type a and other elements, including other navigational elements (see below).
Below the opening link tag, the contents of the