GrapeCity is pleased to announce DataViewsJS, the newest product in our JavaScript product line. DataViewsJS is the ultimate JavaScript data presentation control. Previously under the name Spread.Views, DataViews is a complete overhaul with new features. Whether you are new to DataViews or have used the previous Spread.Views, this article will show you how to get started with DataViewsJS, adding it into your own application.
One of the basic implementations of DataViewsJS is as a simple grid. To add the DataView component to a page in your application, you will need the four required components:
These can be referenced like so:
<link rel="stylesheet" type="text/css" href="/static/dataviews/gc.dataviews.core.css">
<link rel="stylesheet" type="text/css" href="/static/dataviews/gc.dataviews.grid.css">
<script src="/static/dataviews/gc.dataviews.common.js" type="text/javascript"></script>
<script src="/static/dataviews/gc.dataviews.core.js" type="text/javascript"></script>
<script src="/static/dataviews/gc.dataviews.grid.js" type="text/javascript"></script>
Once referenced a simple DIV element can be added:
<div id="grid" class="grid"></div>
And then finally a line of code to initialize it:
new GC.DataViews.DataView('#grid', data, new GC.DataViews.GridLayout());
In addition to the grid layout, DataViews also has a few other layouts:
In this layout, columns are arranged horizontally to present the data like a product catalog:
var dataView = new GC.DataViews.DataView(document.getElementById('grid'), data, columns, new GC.DataViews.HorizontalLayout({}));
This layout includes the masonry and metro layouts, which are essentially similar to the way in which Pinterest is laid out, which elements placed in optimal positions based on vertical space.
var dataView = new GC.DataViews.DataView(document.getElementById('grid'), data, columns, new GC.DataViews.MasonryLayout({gutter: 12, rowTemplate: '#rowTemplate'}));
Cards are the main element of this layout, which are essentially defined blocks that are laid out in rows. These cards can usually be used in a typical grid or in something more complex like a tree column for hierarchical data.
var dataView = new GC.DataViews.DataView(document.getElementById('grid'), data, columns, new GC.DataViews.CardLayout({cardHeight: 250, cardWidth: 290, rowTemplate: '#filmDisplay', direction: 'horizontal'}));
These layouts can then be customized with different grouping strategies that provide a way to arrange the data:
In addition to the different layouts, DataViewsJS has a calculation engine that be used within and without DataViewsJS, allowing you to utilize the powerful calculation on JSON data not necessarily inside of DataViewsJS. This calculation engine give you the ability to create implementations with calculated columns, fields, and column aggregators.
var formula = '=SUMX(FILTER([Country]="United States" && [State]="NY"), [Quantity] * [Price])';
var result = dataView.data.evaluate(formula);
daxSheet.setValue(args.row, 1, result);
While DataViews can be used in pure JavaScript, it has support for other frameworks, including React, Vue, and Angular.
Read more about DataViewsJS:
DataViews Demos | DataViews Documentation