JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>JS Bin</title>
<script
type="text/javascript"
src="http://code.jquery.com/jquery-2.0.2.js"
></script>
<link
rel="stylesheet"
type="text/css"
href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"
/>
<script
type="text/javascript"
src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"
></script>
<link
rel="stylesheet"
type="text/css"
href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css"
/>
</head>
<body>
<div id="tbl"></div>
<ul id="contextMenu" class="dropdown-menu" role="menu">
<li><a href="#" class="link1">Report1</a></li>
<li><a href="#" class="Link2">Report2</a></li>
</ul>
</body>
</html>
JavaScript
var clickedtd = -1;
$(window).load(function() {
$dropdown = $("#contextMenu");
$(".actionButton").click(function() {
clickedtd = $(this).parent().index();
//get row ID
console.log($(this).parent().index());
//move dropdown menu
$(this).after($dropdown);
//update links
$(this).dropdown();
});
$(".link1").click(function(){
console.log("Report 1 : ");
if(clickedtd == 2){
// report 1 JAYANAGAR clicked
console.log("JAYANAGAR");
} else if(clickedtd == 3){
// report 1 MALLESHWARAM clicked
console.log("MALLESHWARAM");
}else if(clickedtd == 4){
// report 1 KOLAR clicked
console.log("KOLAR");
}
});
// Report 2 click event
$(".Link2").click(function(){
console.log("2: "+clickedtd);
if(clickedtd == 2){
// report 2 JAYANAGAR clicked
} else if(clickedtd == 3){
// report 2 MALLESHWARAM clicked
}else if(clickedtd == 4){
// report 2 KOLAR clicked
}
});
});
data= [
{
"amount": 291589,
"billdate": "2018-08-01",
"outlet": "JAYANAGAR"
},
{
"amount": 58337,
"billdate": "2018-08-01",
"outlet": "MALLESHWARAM"
},
{
"amount": 65970,
"billdate": "2018-08-01",
"outlet": "KOLAR"
},
{
"amount": 296125,
"billdate": "2018-08-02",
"outlet": "JAYANAGAR"
},
{
"amount": 56545,
"billdate": "2018-08-02",
"outlet": "MALLESHWARAM"
},
{
"amount": 72213,
"billdate": "2018-08-02",
"outlet": "KOLAR"
},
{
"amount": 346605,
"billdate": "2018-08-03",
"outlet": "JAYANAGAR"
},
{
...