在extjs4中,如何选择tpl';单击其值时单击s单选按钮
我在extjs4中工作。我的tpl视图通过单选按钮显示问题及其选项,如下所示:-在extjs4中,如何选择tpl';单击其值时单击s单选按钮,extjs4,radio-button,Extjs4,Radio Button,我在extjs4中工作。我的tpl视图通过单选按钮显示问题及其选项,如下所示:- Ext.define('Balaee.view.qb.qbqns.QbqnsView', { extend:'Ext.view.View', id:'qbqnsViewId', alias:'widget.QbqnsView', store:'qb.QbqnsStore', cls:'QbqnsView', //aut
Ext.define('Balaee.view.qb.qbqns.QbqnsView',
{
extend:'Ext.view.View',
id:'qbqnsViewId',
alias:'widget.QbqnsView',
store:'qb.QbqnsStore',
cls:'QbqnsView',
//autoScroll: true,
config:
{
tpl:'<tpl for=".">'+
'<div id="main">'+
'</br>'+
'<b><id="q">{#}.{question}</b>'+
'<tpl for="options">'+ // interrogate the kids property within the data
'<p>  <input type="radio" name="{parent.questionId}" value="{optionId}"> {option}</p>'+
//'<p>  <input type="radio" name="{questionId}"> {option}</p>'+
'</tpl></p>'+
// '<p>---------------------------------------------------------</p>'+
'</div>'+
'</tpl>',
itemSelector:'div.main'
}
});
Ext.define('Balaee.view.qb.qbqns.QbqnsView',
{
扩展:'Ext.view.view',
id:'qbqnsViewId',
别名:'widget.QbqnsView',
商店:'qb.QbqnsStore',
cls:“QbqnsView”,
//autoScroll:是的,
配置:
{
第三方物流:''+
''+
“”+
“{#}.{问题}”+
“”+//查询数据中的kids属性
“{option}”+
//“{option}”+
“”+
//“--------------------------------------------------------------”+
''+
'',
项目选择器:'div.main'
}
});
为了检索选定的单选按钮,我编写了如下代码-
var QbqnsStore = this.getStore('qb.QbqnsStore');
var QbqnsModel = this.getModel('qb.QbqnsModel');
QbqnsModel = QbqnsStore.getAt(0);
var answers = '{"data":[';
var i = 0;
QbqnsStore.each(function (model) {
i++;
var inputs = document.getElementsByName(model.get('questionId'));
for (var j = 0; j < inputs.length; j++) {
if (inputs[j].checked) {
answers = answers + '{"paperId":"' + paperNumber + '","userId":"' + userId + '","questionId":"' + inputs[j].name + '","option":' + inputs[j].value + '},'
}
}
});
var QbqnsStore=this.getStore('qb.QbqnsStore');
var QbqnsModel=this.getModel('qb.QbqnsModel');
QbqnsModel=QbqnsStore.getAt(0);
var answers='{“数据”:[';
var i=0;
QbqnsStore.每个(功能(型号){
i++;
var inputs=document.getElementsByName(model.get('questionId');
对于(var j=0;j
因此,它工作正常。但用户需要单击单选按钮来选择它。我希望使功能成为这样一种方式,即即使用户单击单选按钮值,它也应该被选中。因此,如何在extjs4中执行此操作将您的单选输出行修改为以下内容:
<p>  <input type="radio" name="{parent.questionId}" id="{parent.questionId}_{optionId}" value="{optionId}"> <label for="{parent.questionId}_{optionId}">{option}</label></p>'+
{option}'+
注意:您需要确保“{parent.questionId}{optionId}”的id对于dom是唯一的,因此单击标签会为其引用的表单元素触发正确的默认事件
有关标签标签的信息,请参见下文: