How do you add multiple elements to a GridLayout using a single Repeater?
The GridLayout component ensures that rows and columns are sized to fit to the largest item in each cell, but if you want to populate it using a Repeater it seems impossible because a Repeater can only have one delegate.
There is another SO page asking how to do it without a wrapping Item, but I've never seen a wrapping Item solution and don't know why it would not be preferable.
How would you create the following?
Here is the model data for that image:
model: [ // JSON model
{
name: "February:",
types: [
{ name: "R-1", size: 24, color: "red" },
{ name: "O--2", size: 16, color: "orange" },
{ name: "Y---3", size: 8, color: "yellow" },
]
},
{
name: "March:",
types: [
{ name: "G-1", size: 24, color: "green" },
]
},
{
name: "April:",
types: [
{ name: "B-1", size: 24, color: "blue" },
{ name: "I--2", size: 16, color: "indigo" },
{ name: "V---3", size: 8, color: "violet" },
]
},
]
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…