$(function () {
// Used to show output in the API Viewer at runtime,
// defined in external script "apiviewer.js"
var titles = ["Sales Representative", "Sales Manager", "Inside Sales Coordinator", "Vice President, Sales"];
var countries = ["UK", "USA"];
/*----------------- Method & Option Examples -------------------------*/
// process events of checkboxes
$("#enableAddRow").on({
change: function (e) {
$("#grid").igGridUpdating("option", "enableAddRow", $(this).is(":checked"));
}
});
// process events of button
$("#addRow").igButton({
labelText: $("#addRow").val(),
click: function (e) {
var rowObj = {
"EmployeeID": $("#grid").igGrid("rows").length + 1,
"FirstName": $("#firstName").val(),
"LastName": $("#lastName").val(),
"Title": $("#title").val(),
"BirthDate": $("#birthDate").val(),
"PostalCode": $("#postCode").val(),
"Country": $("#country").val()
};
$("#grid").igGridUpdating("addRow", rowObj);
}
});
/*----------------- Instantiation -------------------------*/
$("#grid").igGrid({
virtualization: false,
autoGenerateColumns: false,
renderCheckboxes: true,
primaryKey: "EmployeeID",
columns: [{
// note: if primaryKey is set and data in primary column contains numbers,
// then the dataType: "number" is required, otherwise, dataSource may misbehave
headerText: "Employee ID", key: "EmployeeID", dataType: "number"
...
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.