Setting a data source data source from a basic set

I am trying to install a datagrid fuel source from my main system. The source of the examples is here https://github.com/ExactTarget/fuelux/tree/master/sample .

I'm tired like

(function (root, factory) { if (typeof define === 'function' && define.amd) { define(factory); } else { root.sampleData = factory(); } }(this, function () { return { "geonames": new mycollection ///this will retrurn new collection array as in example }; })); 

And my main rendering consists of the following code to set the data source

  var dataSource = new StaticDataSource({ columns: [ { property: 'username', label: 'Name', sortable: true }, { property: 'username', label: 'Country', sortable: true }, data: this.collection, delay: 250 }); $('#MyGrid').datagrid({ dataSource: dataSource, stretchHeight: true }); 

I get an error. StaticDataSource is undefined.

Can someone explain this to me? Or will I be grateful if you can help me with a link to tutorail, which explains how to set datssource data from the core network? The fuel supplement has good documentation in my opinion.

+1
source share
1 answer

The original data source https://github.com/ExactTarget/fuelux/blob/master/sample/datasource.js allows you to populate the datagrid with a simple JavaScript object that you can get from the Backbone by collection by calling .toJSON() in the collection. Then create an instance of the data source as follows:

https://github.com/ExactTarget/fuelux/blob/master/index.html#L112-L138

(replace the columns with what is needed for your own grid, and replace data: sampleData.geonames with data: yourCollection.toJSON() )

Then you can create a datagrid instance as follows:

https://github.com/ExactTarget/fuelux/blob/master/index.html#L144-L147

NOTE. This requires a one-time snapshot of your data and its transfer to the datagrid. If you want your datagrid to support direct queries against your Backbone collection, you just had to provide a data source that makes these queries against your collection. The data source template allows end developers to connect the datagrid to any data provider. Here is another example of using the Flickr API: http://dailyjs.com/2012/10/29/fuel-ux/

I do not know of any existing examples of data sources specifically for Backbone, but if someone does not beat me, I can create it - I also like Backbone.

+1
source

All Articles