cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              	<!-- General -->
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

  <!-- Data Provider-->
  <script type="text/javascript" src="//s3-us-west-2.amazonaws.com/s.cdpn.io/152047/data.js"></script>

	<!-- GoldenLayout -->
	<script type="text/javascript" src="//golden-layout.com/assets/js/goldenlayout.min.js"></script>
	<link type="text/css" rel="stylesheet" href="//golden-layout.com/assets/css/goldenlayout-base.css" />
	<link type="text/css" rel="stylesheet" href="//golden-layout.com/assets/css/goldenlayout-light-theme.css" />

	<!-- SlickGrid -->
	<link rel="stylesheet" type="text/css" href="//mleibman.github.io/SlickGrid/slick.grid.css" />
	<link rel="stylesheet" type="text/css" href="//mleibman.github.io/SlickGrid/css/smoothness/jquery-ui-1.8.16.custom.css" />

	<link rel="stylesheet" type="text/css" href="//mleibman.github.io/SlickGrid/slick-default-theme.css" />
	<script type="text/javascript" src="//mleibman.github.io/SlickGrid/lib/jquery-ui-1.8.16.custom.min.js"></script>

	<script type="text/javascript" src="//mleibman.github.io/SlickGrid/lib/jquery.event.drag-2.2.js"></script>
	<script type="text/javascript" src="//mleibman.github.io/SlickGrid/slick.core.js"></script>
	<script type="text/javascript" src="//mleibman.github.io/SlickGrid/slick.grid.js"></script>


	
            
          
!
            
              .ui-widget *{
	vertical-align: middle;
	font: 8pt Arial, sans-serif;
}

.slick-cell{
	line-height: 20px;
} 
            
          
!
            
              var myLayout = new GoldenLayout({
  content:[{
    type: 'row',
    content:[{
      type: 'component',
        title:'FTSE 100 (1-50)',
      componentName: 'stockGrid',
      componentState: { 
        symbols: [
          "III","ADN","ADM","AGK","AAL","ANTO",
          "ARM","AHT","ABF","AZN","AV","BAB",
          "BA","BARC","BDEV","BG","BLT","BP",
          "BATS","BLND","BSY","BT.A","BNZL",
          "BRBY","CPI","CCL","CNA","CCH",
          "CPG","CRH","DGE","EZJ","EXPN",
          "FRES","FLG","GFS","GKN","GSK",
          "GLEN","HMSO","HL","HSBA","IMI","IMT",
          "IHG","IAG","ITRK","INTU","ITV","JMAT"
        ]
      }
    },{
      type: 'component',
      componentName: 'stockGrid',
        title:'FTSE 100 (51-100)',
      componentState: {
        symbols:[
          "KGF","LAND","LGEN","LLOY","LSE","MKS",
          "MGGT","MNDI","MRW","NG","NXT","OML","PSON",
          "PSN","PFC","PRU","RRS","RB","REL","REX",
          "RIO","RR","RBS","RDSA","RDSB","RMG","RSA",
          "SAB","SGE","SBRY","SDR","SVT","SHP","SN",
          "SMIN","SPD","SSE","STJ","STAN","SL","TSCO",
          "TPK","TT","TLW","ULVR","UU","VOD","WEIR","WTB","WOS"
        ]
      }
    }]
  }]
});

var StockGridComponent = function( container, state ) {
  this._container = container;
  this._state = state;
  this._grid = null;
  this._stockDataProvider = new StockDataProvider();
  this._columns = [
    {id: "symbol", name: "Symbol", field: "symbol"},
    {id: "company", name: "Company", field: "company"},
    {id: "price", name: "Price", field: "price"},
    {id: "change", name: "Change", field: "change"},
    {id: "changeRel", name: "Change %", field: "changeRel"},
    {id: "volume", name: "Volume", field: "volume"}
  ];
  this._options = {
    editable: false,
    enableAddRow: false,
    enableCellNavigation: true
  };

  container.on( 'open', this._scheduleGridCreation, this );
};

/**
* This method is used to get around a chrome-bug that manifests itself when using popout windows with Slickgrid
* in Codepens.
*
* SlickGrid appends a custom style element to the head section and checks for its presence using the document.styleSheets property.
* This seems to cause a number of issues (https://github.com/mleibman/SlickGrid/issues/223). 
* 
* The specific problem here is, that when opening a new popout window, GoldenLayout moves all link elements from
* the body to the head section (links are in the body in Codepens). Chrome only updates its document.styleSheets array once
* these stylesheets have been loaded - which is correct.
*
* What isn't correct is, that Chrome defers adding the styletag - which doesn't need loading - to the document.styleSheets array until
* all dynamically added link elements are loaded.
*
* To recap: this will happen if all of these conditions are true
*
* - Have link elements in body instead of head
* - Use SlickGrid - I've never seen anything else access the document.styleSheets array
* - Open Popout window - only then does GoldenLayout move link tags around
*
* The work-around is to defer SlickGrid's initialisation until all stylesheets have been loaded - which can be checked
* by attaching event listeners  to the link tag's "load event" or - to make sure that we don't miss a stylesheet that has
* already been loaded - poll the link elements sheet property
*/
StockGridComponent.prototype._scheduleGridCreation = function() {
  var interval = setInterval(function(){
    var stylesheetNodes = $('link[rel=stylesheet]'), i;
    
    for( i = 0; i < stylesheetNodes.length; i++ ) {
      if( stylesheetNodes[ i ].sheet === null ){
        return;
      }
    }
    
    clearInterval( interval );
    this._createGrid();
    
  }.bind( this ), 10 );
};

StockGridComponent.prototype._createGrid = function() {
  this._grid = new Slick.Grid( 
    this._container.getElement(),
    this._stockDataProvider.getStocksBySymbol( this._state.symbols ), 
    this._columns,
    this._options
  );

  this._container.on( 'resize', this._resize, this );
  this._container.on( 'destroy', this._destroy, this );
  this._resize();
};

StockGridComponent.prototype._resize = function() {
  this._grid.resizeCanvas();
  this._grid.autosizeColumns();
};

StockGridComponent.prototype._destroy = function() {
  this._grid.destroy();
};

myLayout.registerComponent( 'stockGrid', StockGridComponent );
myLayout.init();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console