Reputation: 32899
I'm trying to follow the simple example of using a DataView with the SlickGrid jQuery plugin. However I can't work out how the data is added to the DataView.
This are the relevant bits of the source:
var dataView;
var grid;
var data = [];
...
$(function() {
// prepare the data
for (var i=0; i<50000; i++) {
var d = (data[i] = {});
d["id"] = "id_" + i;
... add data to d
}
dataView = new Slick.Data.DataView();
grid = new Slick.Grid("#myGrid", dataView, columns, options);
So the grid is now set up, but how does data
get bound to it? I can't see anywhere in the example where it is added, and so I don't know how to add my own data.
Thanks!
Upvotes: 1
Views: 7570
Reputation: 75
I just downloaded a new version today. Mine shows
$(function () {
var data = [];
for (var i = 1; i < 12; i++) {
data[i] = {
title: "Task " + i,
duration: "5 days",
percentComplete: Math.round(Math.random() * 100),
start: "01/01/2009",
finish: "01/05/2009",
effortDriven: (i % 5 == 0)
};
}
grid = new Slick.Grid("#myGrid", data, columns, options);
})
the data array is were you stick the data.
Upvotes: -1
Reputation: 5747
Look further down in the source of the example - you'll find the following lines:
// initialize the model after all the events have been hooked up
dataView.beginUpdate();
dataView.setItems(data);
That's where the dataView's items are being set to the data in the data[] array.
Upvotes: 5