我正在使用 MVC 架构(我已经阅读了 MVC 上的文档,但我仍然在这里迷路)并且我需要知道如何将记录填充到我的标签上。我知道我必须由商店完成这项工作。
我已经从商店加载了值,但由于某种原因无法在我的面板上显示它。这是我的代码;
大多数示例/书籍都演示了如何在网格中显示,而不是在标签中显示(我知道它必须是相同的逻辑,但我迷路了)。它显示了如何写入 DB/JSON 文件而不显示值。
我需要在标签文本中显示 COUNTRYNAME。这是我正在做的一个示例代码来理解这一点,有人可以帮助我吗?
Ext.define ('ProjectDisplayExample.model.Country',{
extend: 'Ext.data.Model',
//
fields:['countryid','countryname']
//
});
店铺
Ext.define('ProjectDisplayExample.store.Country',{
extend:'Ext.data.Store',
model:'ProjectDisplayExample.model.Country',
remoteGroup:true,
proxy: {
actionMethods : {
read : 'POST',
},
type: 'ajax',
url : '/server/country.php'
}
});
看法
Ext.define('ProjectDisplayExample.view.CountryWindow', {
extend: 'Ext.window.Window',
alias: 'widget.countrywindow',
...........
initComponent: function() {
var st = Ext.getStore('Country');
st.load();
this.items = [
{
items: [
{
xtype: 'panel',
region: 'north',
items: [{
xtype: 'label',
// NEED TO DISPLAY COUNTRT NAME FROM THE STORE HERE
}]
}]
}
更新
var store = ... // Your store
store.on('load', function() {
// here store is loaded and you can do anything you want with it
console.log('store is loaded. number of records = ', store.getCount());
}, this, { single: true });
store.load; // I ADDED THIS LINE.................... <---------
更新 2
this.items = [
{
items: [
{
xtype: 'panel',
region: 'north',
items: [{
xtype: 'label',
name : f
}]
}]