In this example, want to illustrate, how we can use an Action Menu Item, to re-direct to the EP pages of Ax.
Have a look into the following picture.
Have placed the Image button, beside the Project Id.
On the click event of the Image button, calling Ax action menuitem and in the related action menu item class, redirecting to the details page by passing the required arguments.
The following code from the C# web part, click event of Image button.
protected void ImageButton_Click(object sender, EventArgs e)
{
//The following lines for, to get the index of the selected row on the grid.
ImageButton imageeButton = (ImageButton)sender;
GridViewRow row = (GridViewRow)imageeButton.NamingContainer;
AxGridViewTimesheet.SelectedIndex = row.DataItemIndex;
DataSetViewRow dsvr;
//Creating object for Action menu item
AxActionMenuItem projMenuItem = new AxActionMenuItem("PMProjTimesheetView");
Proxy.Args args = new Proxy.Args(this.AxSession.AxaptaAdapter);
//Get the current record
dsvr =
this.AxDataSourceProjListTmp.GetDataSet().DataSetViews["ProjTable"].GetCurrent();
IAxaptaRecordAdapter projTable = dsvr.GetRecord();
//Passing the record to the action menu item class
args.record = projTable;
projMenuItem.Run(args);
}
The following code from the Ax action menu item related class (PMProjTimesheetView)
static void main(Args args)
{
ProjTable projTable;
Weblink link;
;
if (args.dataset() == tablenum(ProjTable))
{
projTable = args.record();
link = new Weblink();
link.record(projTable);
link.menufunction(new WebUrlMenuFunction(weburlitemstr(EPProjTableInfo)));
webSession().redirect(link);
}
}
Aucun commentaire:
Enregistrer un commentaire