PDA

View Full Version : what's the best way to change the sequence of menu items



aj3423
20 Jul 2010, 6:11 AM
the basic gridView has 2 header menu items:
Sort Asc
Sort Desc

then the groupingView extends the gridView, in the renderUI() it adds some other items, now the menu looks like:
SortAsc
Sort Desc
----------
Group by
Show in Groups

then the lockingView extends the groupingView, the menu'll be:
SortAsc
Sort Desc
----------
Group by
Show in Group
----------
Lock
Unlock

so if I need to change the sequence of these items to this:
Lock
Unlock
SortAsc
Sort Desc
Group by
-----------
Show in Group

how to do that?

I tried


// the arr would be an array of itemId,
// in this case it'll be:
// ["lock", "unlock", "asc", "desc", "groupby", "-", "showgroup"]
gridView.adjustHMenuSequence= function(arr) {
var newSeq = [];
var menu = this.hmenu;
Ext.each(arr, function(itemId) {
if(itemId !== '-') {
newSeq.push(menu.get(itemId));
} else {
newSeq.push(new Ext.menu.Separator());
}
});
this.hmenu.items.items = newSeq.slice();
}

grid.on('render', function() {
this.view.adjustHMenuSequence(["lock", "unlock", "asc", "desc", "groupby", "-", "showgroup"]);
}, grid);
when first time click the hdMenu, an error occurs:
c is undefined in Container.js line 812