I am trying to create sample data to test a form Grid. And am using the following function to try and create the data to send to my grid.
// populateFields: Populates data n times a record of data for the SSM form.
// @params: n, fips, products
// @returns: fields
populateFields(n, fips, products) {
var data = [];
var fields = this.getFields();
for(i = 0; i < n; i++) {
var x = {fields[0]: false,
fields[1]: fips[getRandomInt(0, fips.length())],
fields[2]: products[getRandomInt(0, products.length())],
fields[3]: getRandomInt(0, 100)};
data.push(x);
}
return data;
}
Nothing gets populated when I call it. I get an error saying fields[0]: false needs [ token.
Note: This is part of a class, I don't think that matters. I am not sure if you want to see how I call it.
Is it because of jQuery, as in what I am passing the array to.
i.getFields()return varying results? If so, how do you know thatfields[1]has anything to do with "fips" or thatfields[2]is related to "products"?