DEMO: Crosstab with resizers.

by obobruyko

HTML

<link rel="stylesheet" type="text/css" href="http://build-master.jaspersoft.com:7680/jrs-pro-feature-amber-adv/themes/reset.css"> 
<link rel="stylesheet" type="text/css" href="http://build-master.jaspersoft.com:7680/jrs-pro-feature-amber-adv/themes/default/containers.css"> 
<link rel="stylesheet" type="text/css" href="http://build-master.jaspersoft.com:7680/jrs-pro-feature-amber-adv/themes/default/theme.css">
<link rel="stylesheet" type="text/css" href="http://build-master.jaspersoft.com:7680/jrs-pro-feature-amber-adv/scripts/components/table/css/perfect-scrollbar.css">
<link rel="stylesheet" type="text/css" href="http://build-master.jaspersoft.com:7680/jrs-pro-feature-amber-adv/scripts/components/table/css/table.css">
<link rel="stylesheet" type="text/css" href="http://build-master.jaspersoft.com:7680/jrs-pro-feature-amber-adv/scripts/lib/jquery/theme/redmond/jquery-ui-1.10.4-custom.css">
            
<script src="http://build-master.jaspersoft.com:7680/jrs-pro-feature-amber-adv/scripts/lib/require-2.1.10.js"></script>
<script src="http://build-master.jaspersoft.com:7680/jrs-pro-feature-amber-adv/scripts/require.config.js"></script>            
<script>
var __jrsConfigs__ = {    
    contextPath: "http://build-master.jaspersoft.com:7680/jrs-pro-feature-amber-adv",
    userLocale: "en",
   isXdm: true
};
    
require.config({
    baseUrl: __jrsConfigs__.contextPath + "/scripts",
});
</script>

<div id="container" style="margin:20px;height:400px;width:701px"></div>
    
<!--<button id="resizeSelected">Resize selected</button>-->
 
    <div style="margin:60px 40px;">
        <div>
            Height <input id="height" type="text"/>
            <button id="resizeCG">Resize columnGroup</button>
        </div>
        <div>
            Width  <input id="width" type="text"/>
            <button id="resizeRG">Resize rowGroup</button>
        </div>
        
        <div>
            <input id="gridWidth" type="text" placeholder="Grid width"/>
            <input...

JavaScript

require([
    "jquery",
    "components/table/Crosstab",
    "components/table/base/DynamicStrategy",
    "components/table/base/StaticGridDataProvider",
    "components/table/scrollableWidget/ScrollableWidget"
], function($, Crosstab, DynamicStrategy, StaticGridDataProvider, ScrollableWidget) {
    
    //Create data provider
    var dataProvider = new StaticGridDataProvider(gridData).getData,
        headerDataProvider = new StaticGridDataProvider(headerData).getData,
        columnGroupDataProvider = new StaticGridDataProvider(columnGroupData).getData,
        rowGroupDataProvider = new StaticGridDataProvider(rowGroupData).getData,
        colsBufferSize = 5,
        rowsBufferSize = 5;    
    
    //create and init table component
    var crosstab = new Crosstab({
        el: "#container",
        /*strategy: { rows: DynamicStrategy,
         cols: DynamicStrategy},*/
        header: {
            getData: headerDataProvider,
            gridHeight: 100,
            gridWidth: 201,
            colsCount: 3,
            rowsCount: 4,
            colsBufferSize: 100
        },
        columnGroup: {
            getData: columnGroupDataProvider,
            gridHeight: 100,
            gridWidth: 500,
            colsCount: 4,
            rowsCount: 4,
            colsBufferSize: 5       
        },
        rowGroup: {
            getData: rowGroupDataProvider,
            gridHeight: 300,
            gridWidth: 201,
            colsCount: 3,
            rowsCount: 4,
            colsBufferSize: 3        
        },        
        data: {
            getData: dataProvider,
            gridHeight: 300,
            gridWidth: 500,
            colsCount: 5,
            rowsCount: 4,
            colsBufferSize: colsBufferSize,
            rowsBufferSize: rowsBufferSize
        }
    });
    crosstab.render();
    
     // scrollable widget
      var lastHorizontalViewport = Math.ceil(gridData[0].length/colsBufferSize),
          lastVerticalViewport =...