PDA

View Full Version : Error using contextMenu and AjaxEvent



plykkegaard
Mar 14, 2009, 7:22 PM
Hi

I have weird problem trying to call an AjaxEvent using a ContextMenu in a gridpanel
Calling javascripts is working

I have a detailwindow like this sample:
http://examples1.ext.net/#/GridPanel/Miscellaneous/Details_Window_Remote/

Basically the CellClick event is working without any problems I have also a simple button which calls the same AjaxEvent and this is also working

For the contextmenu I have something like this:

ext.Menu _menu = new ext.Menu();
ext.MenuItem _item = null;


_menu.ID = "RowContextMenu";
_menu.EnableTheming = true;


_item = new ext.MenuItem();
_item.Text = "Edit row";
_item.Icon = Coolite.Ext.Web.Icon.TableEdit;
_item.AjaxEvents.Click.Event += new Coolite.Ext.Web.ComponentAjaxEvent.AjaxEventHandle r(ShowDetails);
_item.AjaxEvents.Click.Failure = "Ext.MessageBox.alert('Load failed', 'Error during ajax event!');";
_item.AjaxEvents.Click.EventMask.ShowMask = true;
_menu.Items.Add(_item);

ShowDetails:

protected void ShowDetails(object sender, ext.AjaxEventArgs e)
{
string id = e.ExtraParams["id"];
//this.genericEditor.SetData(int.Parse(id), _table);
this.windowEditor.Show();
}

If I remove the failure check I have this error :
The control with ID 'ctl37' is not Observable

ctl37 is the menuitem
sourcecode from FF goes like this (formatted)

Ext.menu.Item(
{id:"ctl37",ajaxEvents:
{click:{fn:function(el,e)
{var params=arguments;Coolite.AjaxEvent.request(
{eventMask:
{showMask:true},formProxyArg:"form1",control:this});
}
}
},
text:"Rediger",iconCls:"icon-tableedit"
})

Any ideas?

Thanks/Peter

Vladimir
Mar 14, 2009, 7:41 PM
Hi,

Did you recreate menu during AjaxEvent? Try to set ID for each menu item 

plykkegaard
Mar 14, 2009, 8:05 PM
If I check for not Ext.IsAjaxRequest my mnuEdit (previous it was ctl37) control cannot be found

[EDIT]: Oh, if I set a proper ID for the MenuItem it's working like a charm

rgds/Peter

Vladimir
Mar 14, 2009, 8:30 PM
Did you recreate control on each request?  Post code

plykkegaard
Mar 14, 2009, 8:44 PM
I am creating the menu in page_init

I have added proper id's to all menuitems and it's working like a charm

Thanks/Peter