-
-
Save beyond-code-github/e3c978314651bd400e2c to your computer and use it in GitHub Desktop.
Final version of the getData function in Getting Started with Linq to Querystring part 2
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 top = "$top=" + model.pageSize(); | |
var skip = "$skip=" + model.pageSize() * (model.currentPage() - 1); | |
var inlinecount = "$inlinecount=allpages"; | |
var filter = model.FilterModel ? model.FilterModel.getODataFilter() : ""; | |
var oDataOptions = [top, skip, inlinecount]; | |
if (filter) { oDataOptions.splice(0, 0, filter); } | |
$.get("/api/values?" + oDataOptions.join("&"), function(data) { | |
model.count(data.Count); | |
model.records(data.Results); | |
model.headings([]); | |
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