-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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