// Clear the console on every subsequent run.
// There are many points below where you can
// uncomment a console.log to gain better
// understanding of how this code works.
console.clear();
// Define the data to be displayed in the repeater.
function staticDataSource(options, callback) {
// Define the columns for the grid
var columns = [{
'label': 'Name', // Column header label.
'property': 'name', // The JSON property you are binding to.
'sortable': true // Is the column sortable.
}, {
'label': 'Description',
'property': 'description',
'sortable': true
}, {
'label': 'Status',
'property': 'status',
'sortable': true
}, {
'label': 'Category',
'property': 'category',
'sortable': true
}];
// Generate the rows in your dataset.
// NOTE: The property names of your items should
// match the column properties defined above.
function generateDummyData() {
var items = [];
var amountOfItems = 100; //Change this number
var statuses = ['Archived', 'Active', 'Draft'];
var categories = ['New', 'Old', 'Upcoming'];
function getRandomStatus() {
var index = Math.floor(Math.random() * statuses.length);
return statuses[index];
}
function getRandomCategory() {
var index = Math.floor(Math.random() * categories.length);
return categories[index];
}
for (var i = 1; i <= amountOfItems; i++) {
var item = {
id: i,
name: 'Item ' + i,
description: 'Desc ' + i,
status: getRandomStatus(),
category: getRandomCategory()
}
items.push(item);
};
// Uncomment these to see in your console the
// JSON payload produced by this function.
//console.log(JSON.stringify(items));
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.