我对ExtJS非常陌生,并且非常迷失。我创建了一个数据存储 -
cursor = connection.cursor()
SQLCommand = ("IF EXISTS(SELECT 1 FROM msdb.dbo.sysjobs J JOIN
msdb.dbo.sysjobactivity A ON A.job_id = J.job_id WHERE J.name ='dbo.SPNAME' AND
A.run_requested_date IS NOT NULL AND A.stop_execution_date IS NULL) select 'The job is
running!' ELSE select 'The job is not running.'")
cursor.execute(SQLCommand)
results = cursor.fetchone()
sresult= str(results)
while "The job is not running" in sresult:
time.sleep(1)
cursor.execute(SQLCommand)
results = cursor.fetchone()
sresult= str(results)
我现在要做的是为每个部分创建一个面板,使用部分名称(一,二三)作为标题。
我尝试了几种方法,所有方法都是不成功的。我该如何解决这个问题?
编辑 - 我试过的一些例子
var sections = Ext.create('Ext.data.Store', {
data: [
{"section" : "One"},
{"section" : "Two"},
{"section" : "Three"}
]
});
答案 0 :(得分:0)
Ext.define
defines classes, but you want to create new instances of the panel
class and add them to the component hierarchy.
So that's what you have to do (you can add them to any existing and already rendered container component):
var parentContainer = ...
var sectionStore = Ext.getStore(sections);
var allRecords = sectionStore || sectionStore.data("section");
allRecords.each(function(record) {
parentContainer.add({
xtype: 'panel',
title: record,
text: record
});
});
答案 1 :(得分:0)
As you are using Ext.define('Ext.panel.Panel'
, You just only define a panel
. Instead of define you need to use Ext.create()
.
CODE SNIPPET
Ext.application({
name: 'Fiddle',
launch: function () {
var sections = Ext.create('Ext.data.Store', {
data: [{
"section": "One"
}, {
"section": "Two"
}, {
"section": "Three"
}]
}),
fieldSetItems = [];
sections.each(rec => {
fieldSetItems.push({
xtype: 'fieldset',
title: rec.get('section')
});
});
Ext.create({
xtype: 'panel',
title: 'Create Items by store',
items: fieldSetItems,
renderTo: Ext.getBody()
});
}
});