Skip to content

Commit

Permalink
Grid SPF: Add placeholder for widget-based datasource
Browse files Browse the repository at this point in the history
  • Loading branch information
jzaefferer committed Mar 7, 2011
1 parent 57ccb0b commit 411b85a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 16 additions & 1 deletion grid-spf/datasource.js
@@ -1,6 +1,21 @@
// port from https://github.com/brado23/jquery-ui/tree/borisGrid/grid-datamodel2
(function ($) {

// this is what a widget-based datasource could look like
$.widget("ui.datasource", {
defaultElement: null,
_create: function() {
this.source = $.isArray(this.options.source)
? new LocalDataSource(this.options)
: new RemoteDataSource(this.options);
this.source.refresh();
},
toArray: function() {
return this.source.toArray();
}
});


// port from https://github.com/brado23/jquery-ui/tree/borisGrid/grid-datamodel2
$.dataSource = function (options) {
return $.isArray(options.source)
? new LocalDataSource(options)
Expand Down
5 changes: 5 additions & 0 deletions grid-spf/grid.html
Expand Up @@ -49,6 +49,11 @@
var developers = $.dataSource({
source: localDevelopers
});

var dev2 = $.ui.datasource({
source: localDevelopers
})
console.log(dev2.toArray());

$( "#developers-local" ).grid({
columns: [ "firstName", "lastName", "country" ],
Expand Down

0 comments on commit 411b85a

Please sign in to comment.