Sproutcore - gridview grouping
Does the SC.Gridview support grouping? If so, can someone give me some pointers how to get started?
I'm trying to build gridview of tiles separated into logical groups. M开发者_StackOverflow中文版y underlying model is similar to the following:
TestApp.personModel.FIXTURES = [
{
"name" : "Bob",
"group" : "group1"
},
{
"name" : "Alice",
"group" : "group1"
},
{
"name" : "Tom",
"group" : "group2"
}
];
So, for example, I'd like Bob and Alice tiles to be in 1 group and Tom to be a separate group.
I don't want to use the SC.ListView because each item is going to be arbitrarily complex (i.e., not just a name).
Thanks in advance.
As long as you create a controller that has a list of each group (so an SC.ArrayController) that has a list of the personModel objects releated to each group (fire off a query that will group your results per group), the SC.GridView is able to display each group just as you would like. I would recommend to have an "ItemView" that defines how each item in the grid is rendered. This ItemView is linked up with the GridView via the exampleView property.
Have a look at the following code for the EurekaJ application on how the GridView is used to display a list of charts.
https://github.com/joachimhs/EurekaJ/blob/master/EurekaJ.View/apps/EurekaJView/views/chart/chart_grid.js
精彩评论