JSFiddle - React, Tailwind, and code Playground
by sparksterz
HTML
<script src="http://cdn.kendostatic.com/2012.1.515/js/kendo.all.min.js"></script>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2012.1.322/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2012.1.322/styles/kendo.default.min.css">
<div id="grid"></div>
JavaScript
//Our static datasource
var allRecords = [{
"Job": "Worker",
"Name": "Joe Smith",
"Age": 30},
{
"Job": "Farmer",
"Name": "Ryan",
"Age": "62"},
{
"Job": "Manager",
"Name": "Don",
"Age": 66},
{
"Job": "Worker",
"Name": "Bob",
"Age": 22},
{
"Job": "Farmer",
"Name": "Slappy Smith",
"Age": 33}];
//Kendo column helper
function newColumn(field, title, width, type) {
var myColumn = {};
myColumn.field = field;
myColumn.title = title;
myColumn.type = type;
if (width !== undefined) {
myColumn.width = width;
}
return myColumn;
}
//Columns for all people
function PeopleColumnPopulation() {
var columns = [];
var field = "Job";
var title = "Job";
var width = "100px";
var type = "string";
columns[0] = newColumn(field, title, width, type);
field = "Name";
title = "Name";
type = "string";
width = undefined;
columns[1] = newColumn(field, title, width, type);
field = "Age";
title = "Age";
width = "50px";
type = "number";
columns[2] = newColumn(field, title, width, type);
return columns;
}
//The column variable for the grid. Initialized to all people
var gridColumns = PeopleColumnPopulation();
//The data source of the grid. Initialized to all people
var dataSource = new kendo.data.DataSource({
data: allRecords
});
//Create simple grid
$("#grid").kendoGrid({
dataSource: dataSource,
columns: gridColumns,
scrollable: true,
pageable: false,
sortable: true,
filterable: true
});