Crosstab
by obobruyko
HTML
<link rel="stylesheet" type="text/css" href="http://localhost:8080/JRS-pro/scripts/components/table/css/perfect-scrollbar.css">
<link rel="stylesheet" type="text/css" href="http://localhost:8080/JRS-pro/scripts/components/table/css/table.css">
<link rel="stylesheet" type="text/css" href="http://localhost:8080/JRS-pro/scripts/lib/jquery/theme/redmond/jquery-ui-1.8.20.custom.css">
<script src="http://localhost:8080/JRS-pro/scripts/lib/require-jquery-2.1.2.js"></script>
<script src="http://localhost:8080/JRS-pro/scripts/require.config.js"></script>
<script>
var __jrsConfigs__ = {
urlContext : "http://localhost:8080/JRS-pro",
isXdm: true
};
require.config({
baseUrl: __jrsConfigs__.urlContext + "/scripts",
});
</script>
<div id="container" style="margin-top:20px;height:400px;width:701px"></div>
<button id="left" style="margin-top: 50px;">Left</button>
<button id="right">Right</button>
<button id="resizeSelected">Resize selected</button>
<div>
<label>Height:</label>
<input id="height" type="text" value="100"/>
<label>Width:</label>
<input id="width" type="text" value="100"/>
<button id="resizeGrid">Resize grid</button>
</div>
JavaScript
require([
"jquery",
"components/table/Crosstab",
"components/table/base/DynamicGridStrategy",
"components/table/base/StaticGridDataProvider",
], function($, Crosstab, DynamicGridStrategy, StaticGridDataProvider) {
//Create data provider
var dataProvider = new StaticGridDataProvider(gridData).getData,
headerDataProvider = new StaticGridDataProvider(headerData).getData,
columnGroupDataProvider = new StaticGridDataProvider(columnGroupData).getData,
rowGroupDataProvider = new StaticGridDataProvider(rowGroupData).getData;
//create and init table component
var crosstab = new Crosstab({
el: "#container",
header: {
getData: headerDataProvider,
//Strategy: DynamicGridStrategy,
gridHeight: 100,
gridWidth: 201,
colsCount: 3,
rowsCount: 4,
colsBufferSize: 100
},
columnGroup: {
getData: columnGroupDataProvider,
//Strategy: DynamicGridStrategy,
gridHeight: 100,
gridWidth: 500,
colsCount: 10,
rowsCount: 4,
colsBufferSize: 10
},
rowGroup: {
getData: rowGroupDataProvider,
//Strategy: DynamicGridStrategy,
gridHeight: 300,
gridWidth: 201,
colsCount: 3,
rowsCount: 10,
colsBufferSize: 3
},
data: {
getData: dataProvider,
//Strategy: DynamicGridStrategy,
gridHeight: 300,
gridWidth: 500,
colsCount: 10,
rowsCount: 10,
colsBufferSize: 100
}
});
crosstab.render();
$("#left").on("click", function(event) {
var scroollPos = crosstab.scrollPos();
crosstab.scrollTo(scroollPos.top, scroollPos.left - 1);
event.stopPropagation();
});
...