Skip to content

Noodle push() Override

Dan Kranz edited this page Sep 22, 2021 · 4 revisions

Add a new item to the dataset.

Only implement this override if the data source is not an array.

Syntax

push = function(item) { ... }

Parameter Values

Parameter Description
item The item to add, an array or object. The datasource may ignore the parameter.

Example

var items = {
  name: "Test",
  nline: 9,
  data: [
    ["1","Vegetable","Tree","1"],
    ["2","Animal","Bird","1"],
    ["3","Mineral","Diamond","1"],
    ["4","Vegetable","Flower","1"],
    ["5","Vegetable","Grass","1"],
    ["6","Animal","Cat","1"],
    ["7","Animal","Dog","1"],
    ["8","Mineral","Ruby","1"],
    ["9","Mineral","Quartz","1"]
  ]
};
items.push = function(item) {
  // In this case, item is a placeholder.  We ignore it.
  this.nline = this.data.push([]);
}

var db1 = new Noodle(items, ["Seq","Category","Item","Count"]);

// Create a new data view, Items by Category
db1.InitializeView();
db1.EnterHeader(2);
db1.EnterColumnar(3);
db1.GenerateView();

// Add a new row to page one
var nrows = db1.CreateNewLineOnPage(1);  // Makes the following call: items.push({});
Clone this wiki locally