PDA

View Full Version : Is it possible to create such a grid?



ezriel
23 Sep 2012, 8:29 AM
Hello,
is it possible to create such a grid as shown below??
I have two models with hasmany association:


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 example



{"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}
Questions can have different number of answers or if it isn't possible the same number of answers.
Checkbox is used for marking isMarked fields.
Can anyone give me example?
Thanks

scottmartin
24 Sep 2012, 10:31 AM
You could probably use: (pivot grid)
http://www.sencha.com/forum/showthread.php?237492

And then use CheckColumn:
Ext.ux.CheckColumn

or this UX:
http://skirtlesden.com/ux/component-column

This not available out of the box.

Scott.