$(function () {
var customerDataList = []; // Global variable to hold the preloaded customer data
// Function to preload the customer data
function preloadCustomerData() {
return $.ajax({
type: "GET",
url: "https://run.mocky.io/v3/4e14af6b-bf67-4b3c-aedb-48fe2152837e", // Your API URL to get customer data
dataType: "json",
success: function (data) {
// Assuming the API returns an array of customers
customerDataList = data; // Store the customer data globally
},
error: function () {
alert("Error loading customer data");
}
});
}
// Call the function to preload the data before initializing the grid
preloadCustomerData().done(function () {
// Once the customer data is preloaded, initialize the grid
initializeGrid();
});
// Function to initialize the grid
function initializeGrid() {
var gridData = [
{ ID: 1, CustomerID: "CUST01", Name: "John Doe" },
{ ID: 2, CustomerID: "CUST02", Name: "Jane Smith" },
{ ID: 3, CustomerID: "CUST03", Name: "Michael Brown" }
];
$("#grid").igGrid({
primaryKey: "ID",
autoCommit: true,
columns: [
{ headerText: "ID", key: "ID", dataType: "number" },
{ headerText: "Customer", key: "CustomerID", dataType: "string" }
],
dataSource: gridData,
autoGenerateColumns: false,
features: [
{
name: "Updating",
editMode: "dialog",
columnSettings: [
{
columnKey: "CustomerID",
editorType: "combo",
editorOptions: {
mode: "editable",
...
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.