Showing posts with label grid. Show all posts
Showing posts with label grid. Show all posts

Thursday, 23 October 2014

Dynamic Selection in Form

Dynamic Selection in Form


1. On the Class Declaration of the form, add a query filter

    public class FormRun extends ObjectRun
   {
        QueryFilter queryFilterCustId;
    }

2. On the Data Sources ladder of the form, override the init method, note that it has the _ds extension

    public void init()
   {
        super();
        queryFilterCustId = WMPPickingLines_ds.query().addQueryFilter(WMPPickingLines_ds.queryBuildDataSource(),"CustAccount");

    }

3. Change the Control that will be used for the filter to have the property of AutoDeclaration set to Yes 

4. Override the modified method of the control to trigger the query

    public boolean modified()
   {
        boolean ret;
        WMPPickingLines_ds.executeQuery();
        return ret;
    }

5. On the Data Sources ladder of the form, override the executeQuery method, not that the controlName is required (in this case "CustomerId"). ValueStr is the method for getting a value from a drop-down.

public void executeQuery()
{

    QueryFilterCustId.value(element.design().controlName("CustomerId").valueStr());
    super();
} 


Monday, 6 October 2014

Multiline grid selection


When something is clicked, work through the grid to get just the selected lines (ticked or highlighted)

void clicked()
{
    CustPaymModeTable custPaymModeTablelocal;
    MultiSelectionHelper helper = MultiSelectionHelper::construct(); // construct the helper class
    helper.parmDatasource(custPaymModeTable_ds); // set the datasource of the helper
    custPaymModeTablelocal = helper.getFirst(); //get the first selected record of the helper

    while (custPaymModeTablelocal.RecId != 0)
    {
        info(custPaymModeTablelocal.PaymMode);
        custPaymModeTablelocal = helper.getNext(); //get the next selected record of the helper
    }
}


Thursday, 2 October 2014

Ax2012 Parent/Child Linking In Grids


In the Data Sources of the Form, select the child table. In the data category of the child table, set the following;

  • JoinSource = <Parent table Name>
  • Link Type = delayed
  • Name = <Child table name>
  • Table = <Child table name>
Now as the data changes in the parent table grid, the data will change in the child grid.

NB : There has to be a relation set between the two data sources

Display Images In A Grid



  • Step 1 - Declare global variables in <yourform>.classdeclaration
public class FormRun extends ObjectRun
{
    Imagelist imageList;
    Image image;
}
  • Step 2 - Create Image List in <yourForm>.init
public void init()
{
    imageList = new ImageList(ImageList::smallIconWidth(), ImageList::smallIconHeight());
    image = new Image();
    image.loadResource(1030);  // tick icon
    imagelist.add(image);
    image.loadResource(927); // info icon
    imageList.add(image);
    image.loadResource(928); // warning icon
    imageList.add(image);
    image.loadResource(929); // red x icon
    imageList.add(image);

    super();
    
}

  • Step 3 - Create a window field on the grid
Set the AutoDeclaration of the window field to yes in the properties dialog
Load the image list to the window in <yourForm>.init after the super();

public void init()
{
    imageList = new ImageList(ImageList::smallIconWidth(), ImageList::smallIconHeight());
    image = new Image();
    image.loadResource(1030); 
    imagelist.add(image);
    image.loadResource(927);
    imageList.add(image);
    image.loadResource(928);
    imageList.add(image);
    image.loadResource(929);
    imageList.add(image);

    super();
    <windowField>.imageList(imageList);
}

  • Step 4 - Create method to set image on window field
On the table that is driving the grid, add a display method to set the picture in the window field.
The picture set is the data item in the array, not the icon number

public client server display int setIcon()
{
    #define.TickIcon(0)
    #define.InfoIcon(1)
    #define.WarningIcon(2)
    #define.StopIcon(3)

    
    if(!InventTable::find(this.itemNumber))
    {
        return #StopIcon;
    }
    else if(this.qtyOnHand() <= 0)
    {
        return #WarningIcon;
    }

    return #TickIcon;
}


  • Step 5 - Link window field to data
On the properties of the window field to point to the data method in step 4

DataSource  = <table in step 4>
DataMethod = <display method in step 4>