是否可以创建如下所示的网格?我有两个具有许多关联的模型:
Ext.define('Question', {
extend: 'Ext.data.Model',
fields: [
{name: 'questionId', type: 'int', convert: null},
{name: 'content', type: 'string'},
{name: 'type', type: 'int'},
],
hasMany : {model: 'Answer', name: 'answers'},
idProperty: 'questionId'});
Ext.define('Answer', {
extend: 'Ext.data.Model',
fields: [
{name: 'answerId', type: 'int', convert: null},
{name: 'question_id', type: 'int'},//foreignKey
{name: 'content', type: 'string'},
{name: 'isCorrect', type: 'boolean'},
{name: 'isMarked', type: 'boolean'},
],
associations: [
{ type: 'belongsTo', model: 'Question' }
],
idProperty: 'answerId'});
JSON 示例
{"data":[
{"questionId":4100,"content":"12:4?","type":"2","answers":
[{"answerId":1051,"content":"11","isCorrect":true,"isMarked":false},
{"answerId":1052,"content":"11","isCorrect":false,"isMarked":false},
{"answerId":1053,"content":"11","isCorrect":false,"isMarked":false}
]},
{"questionId":4101,"content":"12:4?","type":"2","answers":
[{"answerId":1054,"content":"11","isCorrect":true,"isMarked":false},
{"answerId":1055,"content":"11","isCorrect":false,"isMarked":false},
{"answerId":1056,"content":"11","isCorrect":false,"isMarked":false}
]}],"success":true}
这是显示网格视图的链接 http://imageshack.us/photo/my-images/834/examgrid.jpg/
问题可以有不同数量的答案,或者如果不可能有相同数量的答案。复选框用于标记 isMarked 字段。
谁能给我举个例子?
谢谢