JavaScript is not my strong suit.
I'm looking at the source for a virtualization demo to see how it works and gets the performance it does. (my grid is terrible).
Could someone offer some commentary to the script below to help me understand and maybe learn something? Thanx!
generatePeople(count, function(data) {
var initStart;
var renderStart;
$("#message").text("");
var nextId = data.length + 1;
var dataSource = new kendo.data.DataSource({
pageSize: 20,
transport: {
create: function(e) {
if (e.data.models) {
//batch editing
for (var i = 0; i < e.data.models.length; i++) {
e.data.models[i].Id = nextId++;
}
e.success(e.data.models);
} else {
e.data.Id = nextId++;
e.success(e.data);
}
},
read: function(e) {
e.success(data);
},
update: function(e) {
if (e.data.models) {
//batch editing
e.success(e.data.models);
} else {
e.success(e.data);
}
},
destroy: function(e) {
if (e.data.models) {
//batch editing
e.success(e.data.models);
} else {
e.success(e.data);
}
}
},
schema: {
model: {
id: "Id",
fields: {
Id: { type: "number", editable: false, nullable: true },
FirstName: { type: "string", validation: { required: true } },
LastName: { type: "string" },
City: { type: "string" },
Title: { type: "string" },
}
}
}
});