Skip to content

Instantly share code, notes, and snippets.

@kuon
Created February 22, 2011 15:23
Show Gist options
  • Save kuon/838826 to your computer and use it in GitHub Desktop.
Save kuon/838826 to your computer and use it in GitHub Desktop.
slickgrid with sproutcore
SGUI.TableView = SC.CollectionView.extend({
columns:[],
options:{},
reloadIfNeeded:function() {
var options = this.get('options');
var content = this.get('content');
var columns = this.get('columns');
function getItem(index) {
var scobject = content.objectAt(index);
var flatobject = {};
columns.forEach(function(col) {
flatobject[col.field] = scobject.get(col.field);
});
return flatobject;
}
function getLength() {
return content.get('length');
}
var data = {getLength: getLength, getItem: getItem};
if(!this._grid) {
this._grid = new Slick.Grid(this.$(), data, columns, options);
}
else {
this._grid.setData(data);
this._grid.render();
}
}
});
@kuon
Copy link
Author

kuon commented Feb 22, 2011

Usage example:

table:SGUI.TableView.design({
  contentBinding:"Test.blsController.arrangedObjects",
  options:{
    enableCellNavigation:YES
  },
  columns:[
    {id:'name', name:'Name', field:'name'},
    {id:'street', name:'Street', field:'street'},
  ],
  layout:{width:500,height:500}
})

@AnushaHuddar
Copy link

Hi,
I created my wrapper class same as above but im getting an error that SGUI is not defined.I have updated my build file as config :test, :required => [:slickgrid]. I feel im missing some basic step while integrating. Can anyone guide me through this.

@dhanyaa
Copy link

dhanyaa commented Jun 26, 2014

Hi, I have created the wrapper class as above . but i am getting a error telling "SlickGrid requires a valid container, <$:sc1367>() does not exist in the DOM." Can anyone guide me through this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment