论坛成员
我正在执行一项任务,其中商店从其中加载另一个商店。实际上我需要另一家商店的数据。
我有 assignmentStore 作为
Ext.define('gantt.store.assignmentStore', {
extend : 'Ext.data.Store',
model : 'gantt.model.Assignment',
autoLoad : true,
// Must pass a reference to resource store
resourceStore : Ext.create('gantt.store.resourceStore'),
proxy : {
method: 'GET',
type : 'ajax',
api: {
read : 'projectmanagement/data/assignmentdata.js'//,
//create : 'foo.js',
//update : 'foo.js',
//destroy : 'foo.js'
},
reader : {
type : 'json',
root : 'assignments'
}
},
listeners : {
load : function() {
this.resourceStore.loadData(this.proxy.reader.jsonData.resources);
}
}
});
我的资源商店是
Ext.define('gantt.store.resourceStore', {
extend : 'Ext.data.JsonStore',
model : 'gantt.model.Resource'
});
我的 assignmentData 值是
{
"assignments" : [
{
"Id" : 1,
"TaskId" : 4,
"ResourceId" : 1,
"Units" : 100
},
{
"Id" : 2,
"TaskId" : 4,
"ResourceId" : 2,
"Units" : 80
},
{
"Id" : 3,
"TaskId" : 11,
"ResourceId" : 5,
"Units" : 50
},
{
"Id" : 4,
"TaskId" : 12,
"ResourceId" : 6,
"Units" : 50
}
],
"resources" : [
{"Id" : 1, "Name" : "Mats" },
{"Id" : 2, "Name" : "Nickolay" },
{"Id" : 3, "Name" : "Goran" },
{"Id" : 4, "Name" : "Dan" },
{"Id" : 5, "Name" : "Jake" },
{"Id" : 6, "Name" : "Kim" },
{"Id" : 7, "Name" : "Bart" }
]
}
我的资源面板代码如下
Ext.define('CustomAssignmentCellEditor', {
extend : "Gnt.widget.AssignmentCellEditor",
show: function(){
console.log('SHOW ', this.resourceStore.getCount());
this.callParent(arguments);
}
});
Ext.define('gantt.view.resourcemgt.resourcePanel',{
extend: 'Gnt.panel.Gantt',
alias: 'widget.resourcepanel',
requires: [
'Gnt.panel.Gantt',
'Sch.plugin.TreeCellEditing',
'Gnt.column.PercentDone',
'Gnt.column.StartDate',
'Gnt.column.EndDate',
'Gnt.widget.AssignmentCellEditor',
'Gnt.column.ResourceAssignment',
'Gnt.model.Assignment'
],
height : 400,
width: 1000,
multiSelect : true,
highlightWeekends : true,
showTodayLine : true,
loadMask : true,
enableDependencyDragDrop : false,
snapToIncrement : true,
startDate : new Date(2010,0,11),
endDate : Sch.util.Date.add(new Date(2010,0,11), Sch.util.Date.WEEK, 20),
viewPreset : 'weekAndDayLetter',
// Object with editor and dataIndex defined
leftLabelField : {
dataIndex : 'Name',
editor : { xtype : 'textfield' }
},
// ... or an object with editor and renderer defined
rightLabelField : {
dataIndex : 'Id',
renderer : function(value, record) {
return 'Id: #' + value;
}
},
initComponent: function() {
var me = this;
var resourceStore = Ext.create('gantt.store.resourceStore');
var assignmentStore = Ext.create('gantt.store.assignmentStore');
var taskStore = Ext.create('gantt.store.taskStore');
var assignmentEditor = Ext.create('CustomAssignmentCellEditor', {
assignmentStore : assignmentStore,
resourceStore : resourceStore
});
Ext.apply(me, {
resourceStore : resourceStore,
assignmentStore : assignmentStore,
taskStore : taskStore,
stripeRows : true,
plugins: [
Ext.create('Sch.plugin.TreeCellEditing', {
clicksToEdit: 1
})
],
eventRenderer : function(task) {
if (assignmentStore.findExact('TaskId', task.data.Id) >= 0) {
// This task has resources assigned, show a little icon
return {
ctcls : 'resources-assigned'
};
}
},
// Setup your static columns
columns : [
{
xtype : 'treecolumn',
header : 'Tasks',
dataIndex : 'Name',
width:250
},
{
header : 'Assigned Resources',
width:150,
editor : assignmentEditor,
xtype : 'resourceassigmentcolumn'
}
],
tbar : [
{
text : 'Indent',
iconCls : 'indent',
handler : function() {
var sm = g.lockedGrid.getSelectionModel();
sm.selected.each(function(t) {
t.indent();
});
}
},
{
text : 'Outdent',
iconCls : 'outdent',
handler : function() {
var sm = g.lockedGrid.getSelectionModel();
sm.selected.each(function(t) {
t.outdent();
});
}
}
]
});
me.callParent(arguments);
}
});
我的资源模型是
Ext.define('gantt.model.Resource', {
extend : 'Gnt.model.Resource'
});
实际上,在我的应用程序中,我有一个显示来自 AssignmentStore 的所有数据的网格,并且网格有一个带有选择下拉列表的列,其数据来自 ResourceStore。
所以我确实使用了前面的代码,但是 ResourceStore 没有加载,所以我的下拉选择框显示我是空的下拉列表。
请建议我一些解决方案,我可以尝试解决它。