Created
November 19, 2015 11:51
-
-
Save akorchev/9edce523fa4426c75f68 to your computer and use it in GitHub Desktop.
Revisions
-
akorchev created this gist
Nov 19, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ (function($, undefined) { $.ui5 = $.ui5 || {}; function DataSource(options) { var that = this; that.idMap = {}; $.extend(that, options); } DataSource.prototype = { load: function() { var that = this; that.transport.read(function(result) { var idx, length, data, id = that.reader.id; that.data = data = that.reader.data(result); if (id) { for (idx = 0, length = data.length; idx < length; idx++) { that.idMap[id(data[idx])] = idx; } } else { for (idx = 0, length = data.length; idx < length; idx++) { that.idMap[idx] = idx; } } }); }, find: function(id) { return this.data[this.idMap[id]]; } } $.extend($.ui5, { DataSource: DataSource }); })(jQuery);