require({ baseUrl: 'http://ajax.googleapis.com/ajax/libs/dojo/1.9.3/', packages: [{ name: 'dojo', location: 'dojo' }, { name: 'dgrid', location: 'http://dojofoundation.org/packages/dgrid/js/dgrid' }, { name: 'put-selector', location: 'http://dojofoundation.org/packages/dgrid/js/put-selector' }, { name: 'xstyle', location: 'http://dojofoundation.org/packages/dgrid/js/xstyle' }] }, [ 'dojo/_base/declare', 'dojo/_base/lang', 'dojo/request/script', 'dojo/store/util/QueryResults', 'dgrid/OnDemandGrid' ], function (declare, lang, request, QueryResults, OnDemandGrid) { var GitHubStore = declare(null, { target: '', idProperty: 'number', constructor: function (options) { lang.mixin(this, options); }, get: function (id) { return request(this.target + '/' + id, { jsonp: 'callback' }).then(function (result) { // The information we want is on the 'data' property of the returned results return result.data; }); }, getIdentity: function (object) { return object[this.idProperty]; }, query: function (query, queryOptions) { var resultPromise = request(this.target, { query: query, jsonp: 'callback' }).then(function (result) { // The information we want is on the 'data' property of the returned results return result.data; }); // QueryResults will add the 'total' property as well as iteration methods return QueryResults(resultPromise); } }); var store = new GitHubStore({ target: 'https://api.github.com/repos/SitePen/dgrid/issues' }); var grid = new OnDemandGrid({ store: store, columns: { user: { label: 'Opened by', get: function (rowObject) { return rowObject.user.login; }, sortable: false }, title: { label: 'Title', sortable: false }, number: { label: 'Number', formatter: function (number) { return '<a href="https://github.com/SitePen/dgrid/issues/' + number + '">' + number + '</a>'; }, sortable: false } }, // Unauthenticated GitHub API requests are rate limited to 60/hr noDataMessage: 'GitHub API request rate exceeded - please try later' }, 'grid'); });