JSFiddle - React, Tailwind, and code Playground
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>
<button onclick="FilterClicked(this)">Click for only farmers</button>
JavaScript
//Our static datasource
var allRecords = [{
"Job": "Worker",
"Name": "Joe Smith",
"Age": 30},
{
"Job": "Farmer",
"Name": "Old McDonald",
"Age": "62",
"Crops": 5000000},
{
"Job": "Manager",
"Name": "Donald Trump",
"Age": 66},
{
"Job": "Worker",
"Name": "Bob Northrup",
"Age": 22},
{
"Job": "Farmer",
"Name": "Slappy Joe",
"Age": 33,
"Crops": 10000}];
//Kendo column helper
function newColumn(field, title, width) {
var myColumn = {};
myColumn.field = field;
myColumn.title = title;
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";
columns[0] = newColumn(field, title, width);
field = "Name";
title = "name";
width = undefined;
columns[2] = newColumn(field, title, width);
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
});
//Helper method to build Kendo filter object
function newFilter(field, op, val) {
var myFilter = {};
myFilter.field = field;
myFilter.operator = op;
myFilter.value = val;
return myFilter;
}
//Function which will build columns for a farmer
function FarmerColumnPopulation() {
var columns = [];
var field = "Job";
var title = "Job";
var width = "100px";
columns[0] = newColumn(field, title, width);
field = "Name";
title = "Name";
width = undefined;
columns[1] = newColumn(field, title, width);
field = "Age";
title = "Age";
width = "50px";
columns[2] = newColumn(field, title, width);
field = "Crops";
title = "# of Crops";
width = "100px";
columns[3] = newColumn(field,...