PDA

View Full Version : menu.Item that is not displayed



flamant
10 Feb 2011, 1:13 AM
Hi,
I implemented a context Menu on fields. This context Menu is composed of 4 menu.Items. For 3 menu.Items of them, their visibility are calculated (updateMandCtxMenuAvailability(field, rowId)). And the fourth menu.Item (id: 'getAuditTrailCtxMenu_'+fieldId) should always be visible



if (result instanceof Ext.form.TextField ||
result instanceof Ext.form.TextArea ||
result instanceof Ext.form.NumberField ||
result instanceof Ext.form.DateField ||
result instanceof Ext.form.Checkbox ||
result instanceof Ext.form.ComboBox ) {
result.addListener('afterrender', function(localField) {
var elt = localField.getEl();
elt.fieldId = localField.getId();
elt.rowId = rowId;
elt.rowSeq = rowSeq;
elt.screenSequence = screenSequence;
elt.subjectId = subjectId;
elt.on('contextmenu', function(evt, elRef) {
evt.stopEvent();
var rowId = this.rowId;
var fieldId = this.fieldId;
var rowSeq = this.rowSeq != null ? this.rowSeq : 1;
var screenSequence = this.screenSequence;
var subjectId = this.subjectId;
console.log('ca passe avant');
if (!this.ctxMenu) {
console.log('ca passe apres');
this.ctxMenu = new Ext.menu.Menu({
// id: 'ctxMenu_'+field.getId(),
items: [
{ id: 'addDpCtxMenu_'+fieldId,
text: '<spring:message code="action.DataPending"/>',
iconCls: 's4xx',
rowId: rowId,
fieldId: fieldId,
listeners: {
click: function(item, evt) {
var field = Ext.getCmp(item.fieldId);
if (item.rowId == null) {
var hiddenMandatory = Ext.getCmp(field.getId()+'_MAND');
if (field.fldDp == 'Y') {
hiddenMandatory.setValue('DP');
field.allowBlank = true;
field.validate();
}
} else {
var record = field.jsonStore.getById(field.rowId);
var oldStatus = record.get(field.fieldId+'_STAT');
var newStatus;
if (oldStatus == Status.NEVENT || oldStatus == Status.HIDDEN) {
newStatus = Status.NOTCLE_NEVMAR_DATPEND;
} else {
newStatus = oldStatus.substring(0, 2)+ Status._DATPEND.substring(2,3);
}
record.set(field.fieldId+'_STAT', newStatus);
field.allowBlank = true;
field.validate();
}
item.removeClass('missingConfirmed');
item.removeClass('forceValidation');
item.removeClass('medicalDoctor');
item.addClass('dataPending');
dataPending.push(field);
missingConfirmed.remove(field);
mandatory.remove(field);
updateAllDpMcAvailability();
}
}

},
{ id: 'addMcCtxMenu_'+fieldId,
text: '<spring:message code="action.missingConfirmed"/>',
iconCls: 's2xx',
rowId: rowId,
fieldId: fieldId,
listeners: {
click: function(item, evt) {
var field = Ext.getCmp(item.fieldId);
if (item.rowId == null) {
var hiddenMandatory = Ext.getCmp(field.getId()+'_MAND');
if (field.fldMc == 'Y') {
hiddenMandatory.setValue('MC');
field.allowBlank = true;
}
} else {
var record = field.jsonStore.getById(field.rowId);
var oldStatus = record.get(field.fieldId+'_STAT');
var newStatus;
if (oldStatus == Status.NEVENT || oldStatus == Status.HIDDEN) {
newStatus = Status.NOTCLE_NEVMAR_MISSCONF;
} else {
newStatus = oldStatus.substring(0, 2)+ Status._MISSCONF.substring(2,3);
}
item.removeClass('dataPending');
item.removeClass('forceValidation');
item.removeClass('medicalDoctor');
item.addClass('missingConfirmed');
record.set(field.fieldId+'_STAT', newStatus);
field.allowBlank = true;
}
missingConfirmed.push(field);
dataPending.remove(field);
mandatory.remove(field);
updateAllDpMcAvailability();
}
}

},
{ id: 'forceConstBreakCtxMenu_'+fieldId,
text: '<spring:message code="action.forceConstBreak"/>',
iconCls: 'forceValidBreak',
fieldId: fieldId,
rowId: rowId,
listeners: {
click: function(item, evt) {
var field = Ext.getCmp(item.fieldId);
forceValidationBreak(field, item.rowId);
item.removeClass('dataPending');
item.removeClass('missingConfirmed');
item.removeClass('medicalDoctor');
item.addClass('forceValidation');
}
}

},
{ id: 'getAuditTrailCtxMenu_'+fieldId,
text: '<spring:message code="application.auditTrail"/>',
iconCls: 'auditTrail',
fieldId: fieldId,
subjectId: subjectId,
screenSequence: screenSequence,
rowSeq: rowSeq,
listeners: {
click: function(item, evt) {
var field = Ext.getCmp(item.fieldId);
getAuditTrail(field, item.subjectId, item.screenSequence, item.rowSeq);
}
}

}]
});
}
var field = Ext.getCmp(fieldId);
updateMandCtxMenuAvailability(field, rowId);
this.ctxMenu.showAt([evt.getPageX(), evt.getPageY()]);
});
})

}


And sometimes, the context menu isn't displayed. I only obtain a small square on the page. The <li> elements exist on the page but there is nothing inside it. I checked that the menu is created (the 2 console.log). The problem is that the menu.Items are not correctly created and displayed

Thank you in advance for your answers