2016-02-20 13:31:29 +03:00
|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<link rel="stylesheet" type="text/css" href="treegrid.css" />
|
|
|
|
<link rel="stylesheet" type="text/css" href="../tplext/fht/defaultTheme.css">
|
|
|
|
<script type="text/javascript" src="../tplext/jquery-1.11.2.min.js"></script>
|
|
|
|
<script type="text/javascript" src="../tplext/fht/jquery.fixedheadertable.js"></script>
|
|
|
|
<script type="text/javascript" src="util.js"></script>
|
|
|
|
<script type="text/javascript" src="treegrid.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="scroller"><div class="inner" id="innerdiv">
|
|
|
|
</div></div>
|
|
|
|
<script>
|
|
|
|
<!--
|
2016-02-24 18:48:09 +03:00
|
|
|
onDomReady(function()
|
2016-02-20 13:31:29 +03:00
|
|
|
{
|
2016-02-24 18:48:09 +03:00
|
|
|
var i = {
|
|
|
|
cells: [ 'Payment from Gazprom to Shell 2', '4', '5' ]
|
|
|
|
};
|
2016-03-04 12:27:56 +03:00
|
|
|
var TG = new TreeGrid([], []);
|
2016-02-24 18:48:09 +03:00
|
|
|
TG.table.className = 'grid';
|
2016-03-04 12:27:56 +03:00
|
|
|
document.getElementById('innerdiv').appendChild(TG.table);
|
|
|
|
$(TG.table).fixedHeaderTable({});
|
|
|
|
setTimeout(function() {
|
|
|
|
TG.setHeader([ '', '15 фев', '16 фев', '17 фев', '18 фев', '19 фев', '20 фев', '21 фев' ]);
|
|
|
|
TG.root.setChildren(false, [ {
|
|
|
|
cells: [ 'Payment from Gazprom to Shell', '2', '3' ]
|
|
|
|
} ]);
|
|
|
|
$(TG.table).fixedHeaderTable({});
|
|
|
|
}, 1000);
|
2016-02-24 18:48:09 +03:00
|
|
|
TG.onExpand = function(node)
|
|
|
|
{
|
|
|
|
// Dynamic loading example
|
2016-02-20 13:31:29 +03:00
|
|
|
if (!node.children.length)
|
|
|
|
node.setChildren(false, [ i ]);
|
2016-02-24 18:48:09 +03:00
|
|
|
return true;
|
|
|
|
|
|
|
|
// Another example with delay (emulation of server interaction)
|
|
|
|
setTimeout(function() {
|
|
|
|
if (!node.children.length)
|
|
|
|
node.setChildren(false, [ i ]);
|
|
|
|
node.toggle();
|
|
|
|
}, 100);
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2016-02-25 12:43:03 +03:00
|
|
|
// Cell editing example
|
2016-03-09 23:52:32 +03:00
|
|
|
TG.initCellEditing();
|
2016-02-25 12:43:03 +03:00
|
|
|
|
|
|
|
// Cell selection by mouse drag example
|
2016-02-24 18:48:09 +03:00
|
|
|
var startDrag, dragDiv;
|
2016-03-10 14:26:55 +03:00
|
|
|
addListener(document.body, 'mousedown', function(evt)
|
2016-02-24 18:48:09 +03:00
|
|
|
{
|
2016-03-10 14:26:55 +03:00
|
|
|
var els = TG.table.querySelectorAll('td.selected');
|
|
|
|
for (var i = 0; i < els.length; i++)
|
|
|
|
els[i].className = els[i].className.replace(' selected', '');
|
|
|
|
evt = getEventCoord(evt);
|
|
|
|
if (evt.which != 1)
|
2016-02-25 12:43:03 +03:00
|
|
|
return;
|
2016-02-24 18:48:09 +03:00
|
|
|
startDrag = [ evt.pageX, evt.pageY ];
|
|
|
|
if (!dragDiv)
|
|
|
|
{
|
|
|
|
dragDiv = document.createElement('div');
|
|
|
|
dragDiv.className = 'selection-rect';
|
|
|
|
document.body.appendChild(dragDiv);
|
|
|
|
}
|
|
|
|
});
|
2016-03-10 14:26:55 +03:00
|
|
|
addListener(document.body, 'mousemove', function(evt)
|
2016-02-24 18:48:09 +03:00
|
|
|
{
|
|
|
|
if (startDrag)
|
|
|
|
{
|
2016-03-10 14:26:55 +03:00
|
|
|
evt = getEventCoord(evt);
|
2016-02-25 12:43:03 +03:00
|
|
|
dragDiv.style.display = 'block';
|
2016-02-24 18:48:09 +03:00
|
|
|
if (startDrag[0] < evt.pageX)
|
|
|
|
{
|
|
|
|
dragDiv.style.left = startDrag[0]+'px';
|
|
|
|
dragDiv.style.width = (evt.pageX-startDrag[0])+'px';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dragDiv.style.left = evt.pageX+'px';
|
|
|
|
dragDiv.style.width = (startDrag[0]-evt.pageX)+'px';
|
|
|
|
}
|
|
|
|
if (startDrag[1] < evt.pageY)
|
|
|
|
{
|
|
|
|
dragDiv.style.top = startDrag[1]+'px';
|
|
|
|
dragDiv.style.height = (evt.pageY-startDrag[1])+'px';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dragDiv.style.top = evt.pageY+'px';
|
|
|
|
dragDiv.style.height = (startDrag[1]-evt.pageY)+'px';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2016-03-10 14:26:55 +03:00
|
|
|
addListener(document.body, 'mouseup', function(evt)
|
2016-02-24 18:48:09 +03:00
|
|
|
{
|
|
|
|
if (startDrag)
|
|
|
|
{
|
2016-03-10 14:26:55 +03:00
|
|
|
evt = getEventCoord(evt);
|
2016-02-24 18:48:09 +03:00
|
|
|
dragDiv.style.display = 'none';
|
|
|
|
var x1 = startDrag[0], y1 = startDrag[1], x2 = evt.pageX, y2 = evt.pageY;
|
|
|
|
if (x2 < x1)
|
|
|
|
{
|
|
|
|
var t = x2;
|
|
|
|
x2 = x1;
|
|
|
|
x1 = t;
|
|
|
|
}
|
|
|
|
if (y2 < y1)
|
|
|
|
{
|
|
|
|
var t = y2;
|
|
|
|
y2 = y1;
|
|
|
|
y1 = t;
|
|
|
|
}
|
|
|
|
startDrag = null;
|
2016-02-25 12:43:03 +03:00
|
|
|
if (x2 > x1+10 && y2 > y1+10)
|
|
|
|
{
|
2016-03-10 14:26:55 +03:00
|
|
|
rectangleSelect(TG.table.getElementsByTagName('td'), x1, y1, x2, y2, function()
|
|
|
|
{
|
|
|
|
var e = this.previousSibling;
|
|
|
|
while (e && e.nodeType == 3) e = e.previousSibling;
|
|
|
|
if (e)
|
|
|
|
this.className += ' selected';
|
|
|
|
});
|
2016-02-25 12:43:03 +03:00
|
|
|
return false;
|
|
|
|
}
|
2016-02-24 18:48:09 +03:00
|
|
|
}
|
|
|
|
});
|
2016-02-20 13:31:29 +03:00
|
|
|
});
|
2016-02-24 18:48:09 +03:00
|
|
|
|
2016-03-10 14:26:55 +03:00
|
|
|
function rectangleSelect(elements, x1, y1, x2, y2, cb)
|
2016-02-24 18:48:09 +03:00
|
|
|
{
|
2016-03-10 14:26:55 +03:00
|
|
|
for (var i = 0; i < elements.length; i++)
|
2016-02-24 18:48:09 +03:00
|
|
|
{
|
2016-03-10 14:26:55 +03:00
|
|
|
var offset = getOffset(elements[i]);
|
|
|
|
var w = elements[i].offsetWidth;
|
|
|
|
var h = elements[i].offsetHeight;
|
|
|
|
if (offset.left+w >= x1 && offset.top+h >= y1 && offset.left <= x2 && offset.top <= y2)
|
|
|
|
cb.apply(elements[i]);
|
|
|
|
}
|
2016-02-24 18:48:09 +03:00
|
|
|
}
|
2016-02-20 13:31:29 +03:00
|
|
|
//-->
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|