PDA

View Full Version : cannot obtain 2 sub menu level



flamant
7 Oct 2010, 4:58 AM
Hi,
I try to obtain 2 sub menu level from the node of the treePanel

the first level :


{ id: 'addScreenDataEntryMenuItem',
text:'<spring:message code="action.addScreen"/>',
iconCls: 'duplicateScreenButtonIcon',
listeners : {
beforeshow : function(scope) {
var menu = Ext.getCmp('addScreenDataEntryMenuItem').menu;
menu.removeAll();
getActivitiesFromContextMenu(selectedDataEntryNode);
}
},
menu: []

}
The second level :


function getActivitiesFromContextMenu(node) {
if (node.attributes['entityName'] == 'Subject' || node.attributes['entityName'] == 'Activity') {
var subjectId;
if (node.attributes['entityName'] == 'Subject') {
subjectId = node.attributes['entityId'];
} else {
subjectId = node.parentNode.attributes['entityId'];
}

var conn = new Ext.data.Connection();
conn.request({
url: "<c:url value="/secure/getActivityMultiScreen.htm"/>",
method: 'GET',
params: { subjectId: subjectId },
success: function(response, opts) {
var results = Ext.util.JSON.decode(response.responseText);
var resultTab = results.rows;
var addActivityMenu = Ext.getCmp('addScreenDataEntryMenuItem').menu;
for (var i = 0; i<resultTab.length; i++) {
var activityId = resultTab[i].activityId;
var newItem = new Ext.menu.Item( {
id: 'activityMultiScreenMenuItem'+i,
iconCls: 'activityNode',
activityId: activityId,
text: resultTab[i].activityName,
menu: []
});
newItem.addListener('activate',
function(scope) {
var menu = scope.menu;
menu.removeAll();

getMultiScreenFromContextMenu(scope.id, subjectId, scope.activityId);
}
);
newItem.addListener('deactivate',
function(scope) {
var menu = scope.menu;
menu.removeAll();
}
)
addActivityMenu.add(newItem);
}
},
failure: function(response, opts) {
Ext.Msg.alert('<spring:message code="application.failure"/>', '<spring:message code="subject.getSchedule.failure"/>');
}
});
}

}
The third level :


function getMultiScreenFromContextMenu(id, subjectId, activityId) {

var conn = new Ext.data.Connection();
conn.request({
url: "<c:url value="/secure/getSubjectMultiScreen.htm"/>",
method: 'GET',
params: { subjectId: subjectId, activityId: activityId },
success: function(response, opts) {
var results = Ext.util.JSON.decode(response.responseText);
var resultTab = results.rows;
console.log('id='+id+' subjectId='+subjectId+' activityId='+activityId+' length='+resultTab.length);
var addScreenMenu = Ext.getCmp(id).menu;
for (var i = 0; i<resultTab.length; i++) {
var screenId = resultTab[i].screenId;
var newItem = new Ext.menu.Item( {
id: 'addScreenDataEntryMenuItem'+i,
iconCls: 'duplicateScreenButtonIcon',
screenId: screenId,
text: resultTab[i].screenName
});
newItem.addListener('click',
function() {
addScreen(subjectId, this.screenId);
}
)
addScreenMenu.add(newItem);
}
},
failure: function(response, opts) {
Ext.Msg.alert('<spring:message code="application.failure"/>', '<spring:message code="subject.getSchedule.failure"/>');
}
});
}
The first and second level works fine but the third level doesn't render. I didn't find a solution. I checked that everything is correct on the server side

Thank you in advance for your answers