Friday 28 February 2014

when double click data should add in forms AX 2012:

when double click data should add:

When double clicking on the field what ever the data in that field  can be added in to text field for that one we have to write this method
mouseDblClick()


for example :
first create one table its having some fields as ex(TestEmail)
Value,CurDate,ID,Name,Body




Create one new form(TestEmailForm) with our table(TestEmail)



Here in that form design level u can change the field property  AutoDeclaration to YES
(Which field u want to double click it adds the data to other field text data)
Here in our form if we double click on Value field, Amount field, CurDate field, ID field, Name field
That field data is added the Body field data
As



For double clicking adding the data of field
We will write the method in design level of field as
Design-field(ID)-method-mouseDbCclick()

public int mouseDblClick(int _x, int _y, int _button, boolean _Ctrl, boolean _Shift)
{
    int ret;

    ret = super(_x, _y, _button, _Ctrl, _Shift);

    TestEmail_Body.pasteText(strFmt("%1",TestEmail_ID.valueStr()));
    return ret;
}


Here in this
TestEmail_ID is the design level name of ID field (this can added  in to Body field data)
    TestEmail_Body is the design level name of Body field data(here the other field data will be added )

Like for all the fields design level we can add mouseDbClick method as
Here in Nmae field:
public int mouseDblClick(int _x, int _y, int _button, boolean _Ctrl, boolean _Shift)
{
    int ret;

    ret = super(_x, _y, _button, _Ctrl, _Shift);
    TestEmail_Body.pasteText(strFmt("%1",TestEmail_Name.valueStr()));
    return ret;
}

Here in CurDate field:
public int mouseDblClick(int _x, int _y, int _button, boolean _Ctrl, boolean _Shift)
{
    int ret;

    ret = super(_x, _y, _button, _Ctrl, _Shift);
    TestEmail_Body.pasteText(strFmt("%1",TestEmail_CurDate.valueStr()));
    return ret;
}

Here in Value field:
public int mouseDblClick(int _x, int _y, int _button, boolean _Ctrl, boolean _Shift)
{
    int ret;

    ret = super(_x, _y, _button, _Ctrl, _Shift);
    TestEmail_Body.pasteText(strFmt("%1",TestEmail_Value.valueStr()));
    return ret;
}


Wednesday 19 February 2014

Coloring for the rows in grid based on conditions

Coloring for the rows in grid based on conditions


To display color to the selected row in display option(The code must be placed in the displayOption() method of the datasource.)

public void displayOption(Common _record, FormRowDisplayOption _options)
{
   RentalInquiryTmp rentalInquiry;
    rentalInquiry = _record;
    switch(rentalInquiry.Occupied)
    {
        case NetOccupied::Vacant:
            _options.backColor(65535);
           
            //_options.backColor(WinAPI::RGB2int(161,161,255));
            break;

        case NetOccupied::Occupied:
            _options.backColor(8421631);
          // _options.backColor(WinAPI::RGB2int(255,0,0));
            break;
        case NetOccupied::Inactive:
            _options.backColor(65408);
           //_options.backColor(WinAPI::RGB2int(0,0,255));
            break;
    }
    //super(_record, _options);

}






Coloring Grids in DAX

tutHeres some tips on how to color Grid Cells / rows in DAX. Ive used the prodTable form as an example.The code must be placed in the displayOption() method of the datasource.
Case 1:
Color specific rows
Code :

public void displayOption(Common _record, FormRowDisplayOption _options) 
{ 
prodtable prodtablelocal; 
prodtablelocal = _record; 
Switch(prodtablelocal.ProdStatus) 
{ 
Case ProdStatus::Created: 
_options.backColor(6029311); //Light Yellow 
_options.textColor(12582912); //Blue 
Break;
Case ProdStatus::Completed: 
_options.backColor(16761281); //Light Blue
_options.textColor(12582912); //Blue
Break;
}
} 

Display:


Case 2: Color specific cells 
Code :
 
public void displayOption(Common _record, FormRowDisplayOption _options) 
{
prodtable prodtablelocal; 
prodtablelocal = _record;
Switch(prodtablelocal.ProdStatus)
{
Case ProdStatus::Created: 
_options.backColor(65535); //Light Yellow
_options.affectedElementsByControl(ProdTable_ProdId.id());
Break; 
Case ProdStatus::Released:
_options.backColor(8421631); //Light Red 
_options.affectedElementsByControl(ProdTable_ProdId.id());
Break;
Case ProdStatus::Completed:
_options.backColor(65408); //Light Green
_options.affectedElementsByControl(ProdTable_ProdId.id());
Break; 
}
}

Display:



Now to get the color codes u want , look at the formtutorial_Form_DisplayOptions.
Tweak it a bit by adding this line in
\Forms\tutorial_Form_DisplayOptions\Designs\Design\[ButtonGroup:ButtonGroup]\Button:SetColor\Methods\clicked()

if (conlen(c)) 
{ backColor = WinAPI::RGB2int( conpeek(c,1), conpeek(c,2), conpeek(c,3) ); 
Info(Strfmt("%1",backColor)); // Add this line 
// Clear the display options for the once which allready has been set. 
for (common = custTable_ds.getFirst(); common; common = custTable_ds.getNext()) 
{



Form Splitter in ax 2012

There are 3 types of splitters : X -axis, Y-axis and Y-axis BottomBound
Classes which help for adding splitters are listed below.
·  SysFormSplitter_X
·  SysFormSplitter_Y
·  SysFormSplitter_YBottomBound
Splitter is actually a group control but by setting up some properties on the group control will make it look like a thin line as a seperator.
Let us learn all these splitters one by one with an example.. Follow me to learn splitters..
Y_Axis splitter:
Create a new form with name SR_YAxisSplitter and add 3 new controls to it.
Add a stringEdit control “Name” and set the autodeclaration property as “Yes”
Add a group control “GroupSplitter” and set the proeprties as shown in the image below.







Add another string edit control “Organization” .
Now, your form should like the screen shot below



Modify the classdeclaration method of the form by creating an object of SysFormSplitter_Y as shown below
public class FormRun extends ObjectRun
{
SysFormSplitter_Y _formSplitter;
}
Override the init() method of the form and instantiate the SysFormSplitter_Y class as shown below.

void init()
{
super();
_formSplitter = new SysFormSplitter_Y(groupSplitter,Name,element);
}
Override 3 methods mouseup(), mousedown() and mousemove() methods as shown below





______________________________________________________________________
int mouseUp(int x, int y, int button, boolean ctrl, boolean shift)
{
int ret;
ret = super(x, y, button, ctrl, shift);
Return _formSplitter.mouseUp(x, y, button, ctrl, shift);
}
_______________________________________________________________________
int mouseMove(int x, int y, int button, boolean ctrl, boolean shift)
{
int ret;
ret = super(x, y, button, ctrl, shift);
Return _formSplitter.mouseMove(x,y,button,ctrl,shift);
}
_______________________________________________________________________
int mouseDown(int x, int y, int button, boolean ctrl, boolean shift)
{
int ret;
ret = super(x, y, button, ctrl, shift);
Return _formSplitter.mouseDown(x, y, button, ctrl, shift);
}


There you go.. We are done with the development. Now let’s see how your form look like with your newly created splitter. Below is the screen shot


X_Axis splitter:
Let us learn now how to create X -Axis splitters on the form
Create a new form by name SR_XAxisSplitter as shown below.
Add first group control and set the following properties as shown below
Height : ColumnHeight
Widht : ColumnWidth
Columns: 3
FrameType : None
Below is the screen shot for your reference : Columns property – set to 3



Inside the group add 3 controls
1) StringEdit control “Name” [Autodeclaration property - Yes]
2)GroupSpliiter Control
3)ListView control with properties [Height - ColumnHeight and width as ColumnWidth]
Set the following properties on the GroupSplitter control





Next, paste the following code in the classdeclaration method
public class FormRun extends ObjectRun
{
SysFormSplitter_X _formSplitter;
}

Override the init() method and add the below code
void init()
{
super();
_formSplitter = new SysFormSplitter_X(groupSplitter,Name);
}
Override mouseup, mousemove and mousedown method on the groupsplitter control and add the below code

______________________________________________________________________
int mouseUp(int x, int y, int button, boolean ctrl, boolean shift)
{
int ret;
ret = super(x, y, button, ctrl, shift);
Return _formSplitter.mouseUp(x, y, button, ctrl, shift);
}
______________________________________________________________________
int mouseMove(int x, int y, int button, boolean ctrl, boolean shift)
{
int ret;
ret = super(x, y, button, ctrl, shift);
Return _formSplitter.mouseMove(x,y,button,ctrl,shift);
}
______________________________________________________________________
int mouseDown(int x, int y, int button, boolean ctrl, boolean shift)
{
int ret;
ret = super(x, y, button, ctrl, shift);
Return _formSplitter.mouseDown(x, y, button, ctrl, shift);
}
______________________________________________________________________

That’s it..we are done with X-Axis splitter as well. Now let’s see how the form looks like. Below is the screen shot




Y_Axis BottomBound:
Y-Axis button bound will be used in ListPages forms as a splitter between the grids and any other controls
Below the screenshot – of newly created ListPage. Follow the properties and addition of controls as shown below.





Next, paste the below code in class declaration method
public class FormRun extends ObjectRun
{
SysFormSplitter_YBottomBound splitter;
}

Override the init() method and paste the following code
public void init()
{
#define.startupHeight(175);
super();
splitter = new SysFormSplitter_YBottomBound(grid, ctrlSplitVertical, previewPane, this, #startupHeight);
}
Override the mouseup, mousemove, mousedown methods on the groupsplitter control and paste the below code
int mouseUp(int x, int y, int button, boolean ctrl, boolean shift)
{
int ret;
;
super(x, y, button, ctrl, shift);
ret = splitter.mouseUp(x, y, button, ctrl, shift);
return ret;
}
______________________________________________________________________
int mouseMove(int x, int y, int button, boolean ctrl, boolean shift)
{
int ret;
;
super(x, y, button, ctrl, shift);
ret = splitter.mouseMove(x, y, button, ctrl, shift);
return ret;
}
_____________________________________________________________________
int mouseDown(int x, int y, int button, boolean ctrl, boolean shift)
{
int ret;
;
super(x, y, button, ctrl, shift);
ret = splitter.mouseDown(x, y, button, ctrl, shift);
return ret;
}
______________________________________________________________________

That’s it pals..we are done with the splitter on the list pages. Below is how your listpage look now.