Home > Dynamics Ax > Dynamics Ax EP Web Parts Communication

Dynamics Ax EP Web Parts Communication


Dynamics Ax EP Web Parts Communication (Without using Share point connection)

We have a requirement for developing the two web parts for search criteria and both web parts have to be hosted on the same page.

According to my requirement, I have to place search fields in one web part and grid to be place in second web part.

Depends on the search operation, the grid has to show filtered records.

Web Part -I

Web Part – II

In web part – I,

1)      From the selection box we will select the Client ID or Client name.

2)      In search text box we will enter the value to be search.

3)      Image button to start/initiate the conflict search process. Search functionality will be implemented in button click event of the image button.

 

In web part – II,

1)      Grid will reflect with the filtered dataset.

2)      It will show the filtered records, based on the search.

These two web parts will be hosted in same page called ClientSearch.aspx.

After search operation is completed see the result of the page.

Find the following C# code for filtering the records in AxGrid based on the search criteria.

C# Code:

//This code is implemented in Web Part-I Image button click event.

protected void imgBtnSearchClient_Click(object sender, ImageClickEventArgs e)

{

       

        try

        {

            object[] parmList = new object[1];

           

            parmList[0] = tbSearchClient.Text;

 

            WebPartManager webPartManager = WebPartManager.GetCurrentWebPartManager(this.Page) as WebPartManager;

            AxUserControlWebPart webPart;                  

                      

 

            for (int i = 0; i < webPartManager.WebParts.Count; i++)

            {

               

               //Finding the second webpart in the web part zone

 

                webPart = webPartManager.WebParts[i] as AxUserControlWebPart;

                if (webPart != null && webPart.ManagedContentItem == "CplTmCustomerGrid")

                {

                   

                    //Finding the DataSource of second web part

                    AxDataSource dataSource = webPart.HostedControl.FindControl("DSClient") as AxDataSource;

                   

                   //Depends on search criteria refreshing the datasource of the second web part.

 

                    if (dataSource != null)

                    {

                        switch (ddlClient.SelectedValue)

                        {

                           

                            // filterCustomerId and filterCustomer are two filter methods implemeted on Ax-Dataset.

                            case "1":

                                dataSource.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("filterCustomerId", parmList);

                                break;

                            case "2":

                                dataSource.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("filterCustomer", parmList);

                                break;

 

                        }

 

                        dataSource.GetDataSet().DataSetViews[0].Research();                       

                    }                 

                  

                    break;

                }

            }                       

        }

        catch (System.Exception ex)

        {

            AxExceptionCategory exceptionCategory;

            // This returns true if the exception can be handled here

            if (!AxControlExceptionHandler.TryHandleException(this, ex, out exceptionCategory))

            {

                // The exception is system fatal – in this case we re-throw.                                   

                throw;

            }

        }            

 

}

Rainbow….Island with a palm treeUmbrella.

 

 

Advertisements
Categories: Dynamics Ax
  1. David Castillo
    July 13, 2011 at 3:35 pm

    Do you have a more detail example on where the code would be placed and how the first webpart gets created in VS?

  2. Jacek
    April 24, 2012 at 1:06 pm

    Great code which give me tool for control all web part without reload all page. Thanks!!!!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: