在extjs中如何使用group radioButton

在extjs中如何使用group radioButton,extjs,radio-group,Extjs,Radio Group,我在extjs工作。我想创建一个视图,这样它就可以显示20个问题,每个问题以及带有单选按钮的选项。我创建了视图作为= View= 问题.js Ext.define('Balaee.view.question.Question', { extend: 'Ext.form.Panel', requires: [ 'Balaee.view.question.QuestionView'], id: 'QuestionId', alias: 'widget

我在extjs工作。我想创建一个视图,这样它就可以显示20个问题,每个问题以及带有单选按钮的选项。我创建了视图作为=

View=
问题.js

Ext.define('Balaee.view.question.Question', {
    extend: 'Ext.form.Panel',
    requires: [
        'Balaee.view.question.QuestionView'],
    id: 'QuestionId',
    alias: 'widget.question',
    title: 'Question',
    height: 180,
    items: [{
        xtype: 'questionView',
    },

    ], //end of items square
    buttons: [{
        xtype: 'button',
        fieldLabel: 'Vote',
        name: 'vote',
        formBind: true,
        text: 'submit',
        action: 'voteAction',
    }]
});
QuestionView.js

Ext.define('Balaee.view.question.QuestionView', {
    extend: 'Ext.view.View',
    id: 'QuestionViewId',
    alias: 'widget.questionView',
    store: 'Question',
    config: {
        tpl: '<tpl for=".">' +
            '<div id="main">' +
            '</br>' +
            '<b>Question :-</b> {question}</br>' +
        //'<p>-------------------------------------------</p>'+

        '<tpl for="options">' + // interrogate the kids property                  within the data
        '<p>&nbsp&nbsp<input type="radio" name="opt" >&nbsp{option} </p>' +
            '</tpl></p>' +

            '</div>' +
            '</tpl>',
        itemSelector: 'div.main',
    }
});

因此,如何使用组单选按钮显示选项,以便在单击“提交”按钮后,它将给我所有用户选择的单选按钮选项作为用户选项。请帮助我…

您想在一页上显示几个问题,对吗

首先,您必须稍微更改您的tpl

            '<p>&nbsp&nbsp<input type="radio" name="opt{questionNumber}" >&nbsp{option} </p>'+

这将返回所有选中的单选按钮

检查这个例子,我认为它对您的回答很有用。我如上所述更改了tpl。但在哪里包含上述查询?是否会出现在提交按钮的点击事件中?实际上,我对extjs非常陌生。你能帮帮我吗?你需要一个点击列表器!例如,您可以通过按钮xtype:“button”直接创建侦听器。
xtype:'button',
fieldLabel:'Vote',
name:'vote',
FormBind:true,
text:'submit', 
listeners: { 
    click: function(btn,e,eOpts) {
         var answers = Ext.core.DomQuery.select("input[type='radio']:checked");

          //e.g.: sending the data via AJAX-call to the server
          Ext.Ajax.request({
            url: ' //e.g. answers.php',
            method: 'POST',
            params: {
                answers: answers
             },
            success: function(response) {
               //do something
            },
            failure: function(response) {
                //do something
            }
    }
 }