View 在extjs中,如何将存储绑定到视图,该视图作为项目包含在其他视图中
我在extjs工作。我认为- QbqnsResultmain.jsView 在extjs中,如何将存储绑定到视图,该视图作为项目包含在其他视图中,view,extjs4,store,View,Extjs4,Store,我在extjs工作。我认为- QbqnsResultmain.js Ext.define('Balaee.view.qb.qbqns.QbqnsResultmain', { extend:'Ext.form.Panel', requires:[ 'Balaee.view.qb.qbqns.QbqnsResult' ], id:'QbqnsResultmainId',
Ext.define('Balaee.view.qb.qbqns.QbqnsResultmain',
{
extend:'Ext.form.Panel',
requires:[
'Balaee.view.qb.qbqns.QbqnsResult'
],
id:'QbqnsResultmainId',
alias:'widget.QbqnsResultmain',
title:'Result',
height:400,
items:[
{
xtype:'QbqnsResult',
},
],
buttons:[
{
xtype:'button',
fieldLabel:'review',
action:'getreview',
name:'review',
formBind:true,
text:'Review',
},
{
xtype:'button',
fieldLabel:'papers',
action:'getpapers',
name:'papers',
formBind:true,
text:'Get all papers',
},
]});
和QbqnsResult.js-
Ext.define('Balaee.view.qb.qbqns.QbqnsResult',
{
extend:'Ext.view.View',
id:'QbqnsResultId',
alias:'widget.QbqnsResult',
//store:'kp.PollStore',
store:'qb.QbqnsStore',
config:
{
tpl:'<tpl for="1">'+
'<div id="main">'+
'</br>'+
//'<b>Question :-</b></br>'+
'<h1 id="q">Total number of Questions are:-</h1>{TotalQuestions}</br>'+
'<h1 id="q">Number of attempted Questions:-</h1> {Attempted}</br>'+
'<h1 id="q">Number of correct answers:-</h1> {CorrectAnswers}</br>'+
'<h1 id="q">Total score:-</h1> {Total}</br>'+
'<h1 id="q">Score you got is:-</h1> {Score}</br>'+
'<h1 id="q">percentage you got is:-</h1> {percentage}</br>'+
'<p>---------------------------------------------------------</p>'+
'</div>'+
'</tpl>',
itemSelector:'div.main',
}
});
因此,我想将resultStore绑定到QbqnsResult视图的tpl,我已将其作为xtype包含在QbqnsResultmain视图中。但resultStore绑定到Qbqnsresultmain视图,但不绑定到Qbqnsresult,Qbqnsresult通过其xtype作为项包含在其中。那么如何将存储绑定到它。有人能指导我吗一种方法是:
var worldChaptor3 =temp.add({xtype:'QbqnsResultmain',
id:'QbqnsResultmainId',
store:resultStore});
worldChaptor3.down('QbqnsResultmain > QbqnsResult').bindStore(resultStore);
但是,如果您在QbqnsResultmain
中执行此操作会更好,我将在afterrender
事件中执行此操作,这样,您可以在创建时自动绑定存储
var worldChaptor3 =temp.add({xtype:'QbqnsResultmain',
id:'QbqnsResultmainId',
store:resultStore});
worldChaptor3.down('QbqnsResultmain > QbqnsResult').bindStore(resultStore);