PDA

View Full Version : me.events is undefined me.events[ename] = me.events[ename] |



rushi2440
5 Apr 2012, 10:18 PM
Hi.. sencha forum member I am having one problem with using window containing the panel.

I am having my resource panel code as below

var combo = new Ext.form.ComboBox({
store: new Ext.data.ArrayStore({
id: 0,
fields: [
'Id',
'displayText'
],
data: [[0, 'Low'], [1, 'Normal'], [2, 'High']]
}),
triggerAction: 'all',
mode: 'local',
valueField: 'Id',
displayField: 'displayText'
});


TaskPriority = {
Low : 0,
Normal : 1,
High : 2
};


Ext.define('CustomAssignmentCellEditor', {
extend : "Gnt.widget.AssignmentCellEditor",

show: function(){
console.log('SHOW ', this.resourceStore.getCount());


this.callParent(arguments);
}
});


Ext.define('rms.view.projectmgt.taskResource',{
extend: 'Gnt.panel.Gantt',
alias: 'widget.taskresource',

requires: [
'Gnt.plugin.TaskContextMenu',
'Gnt.column.StartDate',
'Gnt.column.EndDate',
'Gnt.column.Duration',
'Gnt.column.PercentDone',
'Sch.plugin.TreeCellEditing',
'Gnt.column.ResourceAssignment',
'Gnt.widget.AssignmentCellEditor',
'Gnt.model.Assignment',
'Sch.plugin.Pan'
],

height : 400,
width: 1000,
startDate : new Date(2010,0,11),
endDate : Sch.util.Date.add(new Date(2010,0,11), Sch.util.Date.WEEK, 20),

multiSelect : true,
cascadeChanges: true,
viewPreset: 'weekAndDayLetter',
recalculateParents: false,
showTodayLine : true,
showBaseline : true,

highlightWeekends : true,
showTodayLine : true,
loadMask : true,
enableDependencyDragDrop : false,
snapToIncrement : true,
multiSelect: true,
cascadeChanges: true,

// 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;

me.on({
scope: me,
beforeload: function(store,records,options) {
console.log('BEFORE LOAD YAAR panel'+records.params);
console.log('BEFORE LOAD YAAR panel PROJECTID '+records.params['projectid']);
if(records.params['projectid'] != null)
{
return true;
}
else
{
return false;
}
}
});

var assignmentStore = Ext.create('rms.store.assignment');
var resourceStore = assignmentStore.resourceStore;
var taskStore = Ext.data.StoreManager.lookup('task');

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
},
new Gnt.column.StartDate(),
new Gnt.column.Duration(),
new Gnt.column.PercentDone(),
{
header: 'Priority',
width: 50,
dataIndex: 'Priority',
renderer: function (v, m, r) {
switch (v) {
case TaskPriority.Low:
return 'Low';


case TaskPriority.Normal:
return 'Normal';


case TaskPriority.High:
return 'High';
}
},
field: combo
},
{
xtype : 'booleancolumn',
width : 50,

header : 'Manual',

dataIndex : 'ManuallyScheduled',

field : {
xtype : 'combo',
store : [ 'true', 'false' ]
}
},
{
header : 'Assigned Resources',
width:150,
editor : assignmentEditor,
xtype : 'resourceassigmentcolumn'
}
],

tooltipTpl: new Ext.XTemplate(
'<h4 class="tipHeader">{Name}</h4>',
'<table class="taskTip">',
'<tr><td>Start:</td> <td align="right">{[Ext.Date.format(values.StartDate, "y-m-d")]}</td></tr>',
'<tr><td>End:</td> <td align="right">{[Ext.Date.format(Ext.Date.add(values.EndDate, Ext.Date.MILLI, -1), "y-m-d")]}</td></tr>',
'<tr><td>Progress:</td><td align="right">{PercentDone}%</td></tr>',
'</table>'
).compile(),

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);

}
});


my resource panel has two main store

var assignmentStore = Ext.create('rms.store.assignment');
var resourceStore = assignmentStore.resourceStore;
var taskStore = Ext.data.StoreManager.lookup('task');


my assignmentStore code is given below

Ext.define('rms.store.assignment', {
extend: 'Ext.data.Store',
model: 'rms.model.assignmentModel',
storeId: 'assignmentStore',
autoLoad: true,
constructor: function() {
var me = this;
var resourceStore= Ext.create('rms.store.resource');
},
proxy: {
type : 'ajax',
method: 'GET',
reader: new Ext.data.JsonReader({
root: 'assignmentdata',
type : 'json'
}),
writer : new Ext.data.JsonWriter({
root: 'assignmentdata',
type : 'json',
totalPropery: 'total',
successProperty : 'success',
idProperty : 'id',
encode : true,
writeAllFields : true
}),
api: {
read : 'assignment/GetAssignment.action',
create: 'assignment/CreateAssignment.action',
update: 'assignment/UpdateAssignment.action',
destroy: 'assignment/DeleteAssignment.action'
}
},
listeners : {
load : function() {
this.resourceStore.loadData(this.proxy.reader.jsonData.resourcedata);
}
}
});


and my resourceStore code is

Ext.define('rms.store.resource', {
extend: 'Ext.data.Store',
model: 'rms.model.resourceModel',
storeId: 'resourceStore',
autoLoad: true,

proxy: {
type : 'ajax',
method: 'GET',
reader: new Ext.data.JsonReader({
root: 'resourcedata',
type : 'json'
}),
writer : new Ext.data.JsonWriter({
root: 'resourcedata',
type : 'json',
totalPropery: 'total',
successProperty : 'success',
idProperty : 'id',
encode : true,
writeAllFields : true
}),
api: {
read : 'resource/GetResource.action',
create: 'resource/CreateResource.action',
update: 'resource/UpdateResource.action',
destroy: 'resource/DeleteResource.action'
}
}
});


don't know when I load the window containing the resourcepanel I get below error
me.events is undefined
[Break On This Error]

me.events[ename] = me.events[ename] || true;

my window containing the resource panel is

Ext.define('rms.view.projectmgt.taskAdd' ,{
extend: 'Ext.Window',
alias : 'widget.taskaddwindow',
id: 'taskaddwindow',
title: 'Task Management Window',
width: '85%',
height: '85%',
closeAction: 'destroy',
closable : true,
modal: true,
constrain: true,
maximizable: true,
stateful: false,
projectid: null, // this will be set before showing window
layout: 'border',
initComponent: function() {
this.layoutConfig = {
align: 'stretch'
};
this.items = [
{
region: 'center',
xtype: 'taskresource',
//html: 'taskpanel',
width: '85%',
height: '85%'
}
];

this.on({
scope: this,
beforeshow: this.onBeforeShow
});
this.callParent(arguments);
},
onBeforeShow: function() {
var projectid = this.projectid;
if(projectid != null) {
var store = Ext.data.StoreManager.lookup('task');
console.log('BEFOR SHOW ::'+projectid);
//take the projectid as 1
store.read({
params: {'projectid': projectid},
callback: function(options, success, response) {
console.log('RESPONSE FROM SERVER :'+response.responseText);
} //callback
});
var assignmentStore = Ext.data.StoreManager.lookup('assignment');
assignmentStore.load();
}
}
});


Please suggest me what's wrong I had done in my code. And help me to solve it soon as possible.


Yogendra Singh
Sr. Programmer
Kintudesigns.com

mankz
6 Apr 2012, 6:55 AM
You must do "this.callParent(arguments)" in your subclassed store constructor.

rushi2440
6 Apr 2012, 9:34 PM
@mankz

thanks so much for your reply. I did the changes as per you said now my assignmentStore is like below code

Ext.define('rms.store.assignment', {
extend: 'Ext.data.Store',
model: 'rms.model.assignmentModel',
storeId: 'assignmentStore',
autoLoad: true,
constructor: function() {
var me = this;
me.callParent(arguments);
this.resourceStore = Ext.create('rms.store.resource');
},
resourceStore: this.resourceStore,
proxy: {
type : 'ajax',
method: 'GET',
reader: new Ext.data.JsonReader({
root: 'assignmentdata',
type : 'json'
}),
writer : new Ext.data.JsonWriter({
root: 'assignmentdata',
type : 'json',
totalPropery: 'total',
successProperty : 'success',
idProperty : 'id',
encode : true,
writeAllFields : true
}),
api: {
read : 'assignment/GetAssignment.action',
create: 'assignment/CreateAssignment.action',
update: 'assignment/UpdateAssignment.action',
destroy: 'assignment/DeleteAssignment.action'
}
}
});


and my resourceStore code is like below

Ext.define('rms.store.resource', {
extend: 'Ext.data.Store',
model: 'rms.model.resourceModel',
storeId: 'resourceStore',
autoLoad: true,
proxy: {
type : 'ajax',
method: 'GET',
reader: new Ext.data.JsonReader({
root: 'resourcedata',
type : 'json'
}),
writer : new Ext.data.JsonWriter({
root: 'resourcedata',
type : 'json',
totalPropery: 'total',
successProperty : 'success',
idProperty : 'id',
encode : true,
writeAllFields : true
}),
api: {
read : 'resource/GetResource.action',
create: 'resource/CreateResource.action',
update: 'resource/UpdateResource.action',
destroy: 'resource/DeleteResource.action'
}
}
});


my store loads correctly and when I select the Assigned Resource column also shows me the resource correctly like below image snap
33727

In my resourcePanel I am having store defined as below

var assignmentStore = Ext.data.StoreManager.lookup('assignment');
var resourceStore = Ext.data.StoreManager.lookup('resource');
var taskStore = Ext.data.StoreManager.lookup('task');
var dependencyStore = Ext.data.StoreManager.lookup('dependency');


var assignmentEditor = Ext.create('CustomAssignmentCellEditor', {
assignmentStore : assignmentStore,
resourceStore : resourceStore
});


even though my resource also get loads successfully as above, when I select the resource and then press the saveClose button . The selected resource is not viewed in the column also I am not able to send the resource to server to persist it.


please suggest me some solution why the column didn't show me the selected resource.


Yogendra Singh
Sr. Programmer
Kintudesigns.com