Thursday, May 24, 2012

Build your own context menu on Form field.

Context menu on field are nothing but the list of features shown when you do right click on field like filter by field,by selection ,setup etc.
Following code illustrates how you can override the standard context menu and build your own .
Best use of this is in-case of display methods where filter by field and selection are not available.
Override the standard context method available on Form fields. 

public void context()
{

PopupMenu menu ;
Str filterValue;
int selectedItem;
int filter, removeFilter;
;

//super(); // Comment standard menu

menu = new PopupMenu(element.hWnd());
filter = menu.insertItem("Filter");
removeFilter= menu.insertItem("Remove Filter");

selectedItem = menu.draw();
filterValue = element.design().controlName("Table1_Usn").valueStr();

switch (selectedItem)
{
case filter :
Table1_ds.filter(fieldnum(table1,Usn),filterValue);
break;

case removeFilter :
Table1_ds.removeFilter();
break;

}
}

No comments:

How to identify the user that was used to change an object from AOT in AX2012

Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...