Skip to content

Instantly share code, notes, and snippets.

@beyond-code-github
Last active December 18, 2015 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beyond-code-github/07c97e1dc30fc0fd315b to your computer and use it in GitHub Desktop.
Save beyond-code-github/07c97e1dc30fc0fd315b to your computer and use it in GitHub Desktop.
getData function after modifications to read headers from properties on our model
model.getData = function () {
var skip = model.pageSize() * (model.currentPage() - 1);
$.get("/api/values?$top=" + model.pageSize() + "&$skip=" + skip + "&$inlinecount=allpages", function (data) {
model.count(data.Count);
model.records(data.Results);
// If we have a valid results set, iterate over each property in the first row to get headers
if (data.Results && data.Results.length > 0) {
for (prop in data.Results[0]) {
if (data.Results[0].hasOwnProperty(prop)) {
model.headings.push(prop);
}
}
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment